Gathering results of methods in one List with Prolog











up vote
1
down vote

favorite












So I am trying to

I am defining the sets with is_a(b, a), is_a(c, a), which for simplicity would look visually something like this:



      a
b c
d e f g


I want to give in the list [b, c] and as a result get the list [d, e, f, g]



At the moment when I give in a node or a variable, then it can find everything that is underneath it with this method:



find_nodes(Root, Root) :-
+ is_a(_, Root).
find_nodes(Root, X) :-
is_a(Node, Root),
find_nodes(Node, X).


Which when run gives me the result I need :



?- find_nodes(b, X).
X = d.
X = e.


But it is not in a list, so I have tried :



?- all_nodes([b, c], X).

all_nodes(, _).
all_nodes([H|T], [R|Res]):-
findall(L, find_nodes(H, L), R),
all_nodes(T, Res).


Which gives me - X = [[d, e], [f, g]|_4040], which consists of lists within lists, but I need just 1 list, that would be X = [d, e, f, g].



What am I doing wrong here?



EDIT



Like @lurker said findall returns a list and adding list to a list will give the result I get right now.



The one thing I also tried was using:



all_nodes(, _).
all_nodes([H|T], [R|Res]):-
find_nodes(H, R),
all_nodes(T, Res).


But well that one does not work either because It only gives me 1 element, which in this case is d and then f.










share|improve this question
























  • findall(...) has a list as its third argument. So when you call findall(L, find_nodes(H, L), R). R is a list. So [R|Res] is a list whose first element is itself a list, R. Your other issue is your base case. all_nodes(, _) says that all nodes of an empty list is anything you want since _ is an anonymous variable. It can be anything.
    – lurker
    Nov 8 at 1:06










  • @lurker all_nodes(, _) didnt really know what else to put there, probably could also work. But how can I do it without using findall because when i do it without and call the function recursively while replacing findall to just find_nodes then it takes only the d and goes to the next head.
    – user9441470
    Nov 8 at 1:14








  • 1




    Well, _ does not work because it really does mean that your rule says, finding the nodes for the empty list is anything is a successful result, which obviously isn't logical. would be more logical, would it not? Isn't the result of finding all nodes in an empty tree an empty list specifically?
    – lurker
    Nov 8 at 1:59






  • 1




    You can use findall. You just can't directly use the result the way you are trying to use it. You would need to concatenate the result to your current list of known nodes.
    – lurker
    Nov 8 at 2:00






  • 1




    SWI Prolog also has append(ListOfLists, List) you can check out.
    – lurker
    Nov 8 at 2:07















up vote
1
down vote

favorite












So I am trying to

I am defining the sets with is_a(b, a), is_a(c, a), which for simplicity would look visually something like this:



      a
b c
d e f g


I want to give in the list [b, c] and as a result get the list [d, e, f, g]



At the moment when I give in a node or a variable, then it can find everything that is underneath it with this method:



find_nodes(Root, Root) :-
+ is_a(_, Root).
find_nodes(Root, X) :-
is_a(Node, Root),
find_nodes(Node, X).


Which when run gives me the result I need :



?- find_nodes(b, X).
X = d.
X = e.


But it is not in a list, so I have tried :



?- all_nodes([b, c], X).

all_nodes(, _).
all_nodes([H|T], [R|Res]):-
findall(L, find_nodes(H, L), R),
all_nodes(T, Res).


Which gives me - X = [[d, e], [f, g]|_4040], which consists of lists within lists, but I need just 1 list, that would be X = [d, e, f, g].



What am I doing wrong here?



EDIT



Like @lurker said findall returns a list and adding list to a list will give the result I get right now.



The one thing I also tried was using:



all_nodes(, _).
all_nodes([H|T], [R|Res]):-
find_nodes(H, R),
all_nodes(T, Res).


But well that one does not work either because It only gives me 1 element, which in this case is d and then f.










share|improve this question
























  • findall(...) has a list as its third argument. So when you call findall(L, find_nodes(H, L), R). R is a list. So [R|Res] is a list whose first element is itself a list, R. Your other issue is your base case. all_nodes(, _) says that all nodes of an empty list is anything you want since _ is an anonymous variable. It can be anything.
    – lurker
    Nov 8 at 1:06










  • @lurker all_nodes(, _) didnt really know what else to put there, probably could also work. But how can I do it without using findall because when i do it without and call the function recursively while replacing findall to just find_nodes then it takes only the d and goes to the next head.
    – user9441470
    Nov 8 at 1:14








  • 1




    Well, _ does not work because it really does mean that your rule says, finding the nodes for the empty list is anything is a successful result, which obviously isn't logical. would be more logical, would it not? Isn't the result of finding all nodes in an empty tree an empty list specifically?
    – lurker
    Nov 8 at 1:59






  • 1




    You can use findall. You just can't directly use the result the way you are trying to use it. You would need to concatenate the result to your current list of known nodes.
    – lurker
    Nov 8 at 2:00






  • 1




    SWI Prolog also has append(ListOfLists, List) you can check out.
    – lurker
    Nov 8 at 2:07













up vote
1
down vote

favorite









up vote
1
down vote

favorite











So I am trying to

I am defining the sets with is_a(b, a), is_a(c, a), which for simplicity would look visually something like this:



      a
b c
d e f g


I want to give in the list [b, c] and as a result get the list [d, e, f, g]



At the moment when I give in a node or a variable, then it can find everything that is underneath it with this method:



find_nodes(Root, Root) :-
+ is_a(_, Root).
find_nodes(Root, X) :-
is_a(Node, Root),
find_nodes(Node, X).


Which when run gives me the result I need :



?- find_nodes(b, X).
X = d.
X = e.


But it is not in a list, so I have tried :



?- all_nodes([b, c], X).

all_nodes(, _).
all_nodes([H|T], [R|Res]):-
findall(L, find_nodes(H, L), R),
all_nodes(T, Res).


Which gives me - X = [[d, e], [f, g]|_4040], which consists of lists within lists, but I need just 1 list, that would be X = [d, e, f, g].



What am I doing wrong here?



EDIT



Like @lurker said findall returns a list and adding list to a list will give the result I get right now.



The one thing I also tried was using:



all_nodes(, _).
all_nodes([H|T], [R|Res]):-
find_nodes(H, R),
all_nodes(T, Res).


But well that one does not work either because It only gives me 1 element, which in this case is d and then f.










share|improve this question















So I am trying to

I am defining the sets with is_a(b, a), is_a(c, a), which for simplicity would look visually something like this:



      a
b c
d e f g


I want to give in the list [b, c] and as a result get the list [d, e, f, g]



At the moment when I give in a node or a variable, then it can find everything that is underneath it with this method:



find_nodes(Root, Root) :-
+ is_a(_, Root).
find_nodes(Root, X) :-
is_a(Node, Root),
find_nodes(Node, X).


Which when run gives me the result I need :



?- find_nodes(b, X).
X = d.
X = e.


But it is not in a list, so I have tried :



?- all_nodes([b, c], X).

all_nodes(, _).
all_nodes([H|T], [R|Res]):-
findall(L, find_nodes(H, L), R),
all_nodes(T, Res).


Which gives me - X = [[d, e], [f, g]|_4040], which consists of lists within lists, but I need just 1 list, that would be X = [d, e, f, g].



What am I doing wrong here?



EDIT



Like @lurker said findall returns a list and adding list to a list will give the result I get right now.



The one thing I also tried was using:



all_nodes(, _).
all_nodes([H|T], [R|Res]):-
find_nodes(H, R),
all_nodes(T, Res).


But well that one does not work either because It only gives me 1 element, which in this case is d and then f.







list prolog






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 1:22

























asked Nov 8 at 1:04







user9441470



















  • findall(...) has a list as its third argument. So when you call findall(L, find_nodes(H, L), R). R is a list. So [R|Res] is a list whose first element is itself a list, R. Your other issue is your base case. all_nodes(, _) says that all nodes of an empty list is anything you want since _ is an anonymous variable. It can be anything.
    – lurker
    Nov 8 at 1:06










  • @lurker all_nodes(, _) didnt really know what else to put there, probably could also work. But how can I do it without using findall because when i do it without and call the function recursively while replacing findall to just find_nodes then it takes only the d and goes to the next head.
    – user9441470
    Nov 8 at 1:14








  • 1




    Well, _ does not work because it really does mean that your rule says, finding the nodes for the empty list is anything is a successful result, which obviously isn't logical. would be more logical, would it not? Isn't the result of finding all nodes in an empty tree an empty list specifically?
    – lurker
    Nov 8 at 1:59






  • 1




    You can use findall. You just can't directly use the result the way you are trying to use it. You would need to concatenate the result to your current list of known nodes.
    – lurker
    Nov 8 at 2:00






  • 1




    SWI Prolog also has append(ListOfLists, List) you can check out.
    – lurker
    Nov 8 at 2:07


















  • findall(...) has a list as its third argument. So when you call findall(L, find_nodes(H, L), R). R is a list. So [R|Res] is a list whose first element is itself a list, R. Your other issue is your base case. all_nodes(, _) says that all nodes of an empty list is anything you want since _ is an anonymous variable. It can be anything.
    – lurker
    Nov 8 at 1:06










  • @lurker all_nodes(, _) didnt really know what else to put there, probably could also work. But how can I do it without using findall because when i do it without and call the function recursively while replacing findall to just find_nodes then it takes only the d and goes to the next head.
    – user9441470
    Nov 8 at 1:14








  • 1




    Well, _ does not work because it really does mean that your rule says, finding the nodes for the empty list is anything is a successful result, which obviously isn't logical. would be more logical, would it not? Isn't the result of finding all nodes in an empty tree an empty list specifically?
    – lurker
    Nov 8 at 1:59






  • 1




    You can use findall. You just can't directly use the result the way you are trying to use it. You would need to concatenate the result to your current list of known nodes.
    – lurker
    Nov 8 at 2:00






  • 1




    SWI Prolog also has append(ListOfLists, List) you can check out.
    – lurker
    Nov 8 at 2:07
















findall(...) has a list as its third argument. So when you call findall(L, find_nodes(H, L), R). R is a list. So [R|Res] is a list whose first element is itself a list, R. Your other issue is your base case. all_nodes(, _) says that all nodes of an empty list is anything you want since _ is an anonymous variable. It can be anything.
– lurker
Nov 8 at 1:06




findall(...) has a list as its third argument. So when you call findall(L, find_nodes(H, L), R). R is a list. So [R|Res] is a list whose first element is itself a list, R. Your other issue is your base case. all_nodes(, _) says that all nodes of an empty list is anything you want since _ is an anonymous variable. It can be anything.
– lurker
Nov 8 at 1:06












@lurker all_nodes(, _) didnt really know what else to put there, probably could also work. But how can I do it without using findall because when i do it without and call the function recursively while replacing findall to just find_nodes then it takes only the d and goes to the next head.
– user9441470
Nov 8 at 1:14






@lurker all_nodes(, _) didnt really know what else to put there, probably could also work. But how can I do it without using findall because when i do it without and call the function recursively while replacing findall to just find_nodes then it takes only the d and goes to the next head.
– user9441470
Nov 8 at 1:14






1




1




Well, _ does not work because it really does mean that your rule says, finding the nodes for the empty list is anything is a successful result, which obviously isn't logical. would be more logical, would it not? Isn't the result of finding all nodes in an empty tree an empty list specifically?
– lurker
Nov 8 at 1:59




Well, _ does not work because it really does mean that your rule says, finding the nodes for the empty list is anything is a successful result, which obviously isn't logical. would be more logical, would it not? Isn't the result of finding all nodes in an empty tree an empty list specifically?
– lurker
Nov 8 at 1:59




1




1




You can use findall. You just can't directly use the result the way you are trying to use it. You would need to concatenate the result to your current list of known nodes.
– lurker
Nov 8 at 2:00




You can use findall. You just can't directly use the result the way you are trying to use it. You would need to concatenate the result to your current list of known nodes.
– lurker
Nov 8 at 2:00




1




1




SWI Prolog also has append(ListOfLists, List) you can check out.
– lurker
Nov 8 at 2:07




SWI Prolog also has append(ListOfLists, List) you can check out.
– lurker
Nov 8 at 2:07












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










You can take advantage of the de facto standard findall/4 (*) predicate to solve the problem. This predicate is a variant of the standard findall/3 predicate that allows passing a tail for the list of solutions collected by the predicate. For example:



?- findall(N, (N=1; N=2; N=3), L, [4,5]).
L = [1, 2, 3, 4, 5].


In the following solution, I have renamed predicates and variables for clarity and modified your node leaf predicate:



is_a(a, b).
is_a(a, c).

is_a(b, d).
is_a(b, e).

is_a(c, f).
is_a(c, g).

leaf(Leaf, Leaf) :-
+ is_a(Leaf, _).
leaf(Node, Leaf) :-
is_a(Node, Child),
leaf(Child, Leaf).

all_nodes(, ).
all_nodes([Node| Nodes], Leaves):-
findall(Leaf, leaf(Node, Leaf), Leaves, Tail),
all_nodes(Nodes, Tail).


Sample calls:



?- all_nodes([b, c], X).
X = [d, e, f, g].

?- all_nodes([a], X).
X = [d, e, f, g].

?- all_nodes([b], X).
X = [d, e].


(*) It's a built-in predicate in GNU Prolog, JIProlog, Lean Prolog, O-Prolog, SICStus Prolog, SWI-Prolog, XSB, and YAP (possibly others).






share|improve this answer























  • With this method if I am calling the leaf node all_nodes([d, e], X) then it returns X = [d, e], is there a way to not return the nodes that were called, even if they are leaves?.
    – user9441470
    Nov 8 at 10:54






  • 1




    Try modifying the findall/4 goal argument to (leaf(Node, Leaf), Node == Leaf).
    – Paulo Moura
    Nov 8 at 10:57










  • It does not work at all with this
    – user9441470
    Nov 8 at 10:59






  • 1




    Yes, it does. Likely you made a typo modifying the findall/4 goal argument. You want findall(Leaf, (leaf(Node, Leaf), Node == Leaf), Leaves, Tail). With this change your get L = for the query all_nodes([d, e], L).
    – Paulo Moura
    Nov 8 at 11:03











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53200160%2fgathering-results-of-methods-in-one-list-with-prolog%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown
























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










You can take advantage of the de facto standard findall/4 (*) predicate to solve the problem. This predicate is a variant of the standard findall/3 predicate that allows passing a tail for the list of solutions collected by the predicate. For example:



?- findall(N, (N=1; N=2; N=3), L, [4,5]).
L = [1, 2, 3, 4, 5].


In the following solution, I have renamed predicates and variables for clarity and modified your node leaf predicate:



is_a(a, b).
is_a(a, c).

is_a(b, d).
is_a(b, e).

is_a(c, f).
is_a(c, g).

leaf(Leaf, Leaf) :-
+ is_a(Leaf, _).
leaf(Node, Leaf) :-
is_a(Node, Child),
leaf(Child, Leaf).

all_nodes(, ).
all_nodes([Node| Nodes], Leaves):-
findall(Leaf, leaf(Node, Leaf), Leaves, Tail),
all_nodes(Nodes, Tail).


Sample calls:



?- all_nodes([b, c], X).
X = [d, e, f, g].

?- all_nodes([a], X).
X = [d, e, f, g].

?- all_nodes([b], X).
X = [d, e].


(*) It's a built-in predicate in GNU Prolog, JIProlog, Lean Prolog, O-Prolog, SICStus Prolog, SWI-Prolog, XSB, and YAP (possibly others).






share|improve this answer























  • With this method if I am calling the leaf node all_nodes([d, e], X) then it returns X = [d, e], is there a way to not return the nodes that were called, even if they are leaves?.
    – user9441470
    Nov 8 at 10:54






  • 1




    Try modifying the findall/4 goal argument to (leaf(Node, Leaf), Node == Leaf).
    – Paulo Moura
    Nov 8 at 10:57










  • It does not work at all with this
    – user9441470
    Nov 8 at 10:59






  • 1




    Yes, it does. Likely you made a typo modifying the findall/4 goal argument. You want findall(Leaf, (leaf(Node, Leaf), Node == Leaf), Leaves, Tail). With this change your get L = for the query all_nodes([d, e], L).
    – Paulo Moura
    Nov 8 at 11:03















up vote
1
down vote



accepted










You can take advantage of the de facto standard findall/4 (*) predicate to solve the problem. This predicate is a variant of the standard findall/3 predicate that allows passing a tail for the list of solutions collected by the predicate. For example:



?- findall(N, (N=1; N=2; N=3), L, [4,5]).
L = [1, 2, 3, 4, 5].


In the following solution, I have renamed predicates and variables for clarity and modified your node leaf predicate:



is_a(a, b).
is_a(a, c).

is_a(b, d).
is_a(b, e).

is_a(c, f).
is_a(c, g).

leaf(Leaf, Leaf) :-
+ is_a(Leaf, _).
leaf(Node, Leaf) :-
is_a(Node, Child),
leaf(Child, Leaf).

all_nodes(, ).
all_nodes([Node| Nodes], Leaves):-
findall(Leaf, leaf(Node, Leaf), Leaves, Tail),
all_nodes(Nodes, Tail).


Sample calls:



?- all_nodes([b, c], X).
X = [d, e, f, g].

?- all_nodes([a], X).
X = [d, e, f, g].

?- all_nodes([b], X).
X = [d, e].


(*) It's a built-in predicate in GNU Prolog, JIProlog, Lean Prolog, O-Prolog, SICStus Prolog, SWI-Prolog, XSB, and YAP (possibly others).






share|improve this answer























  • With this method if I am calling the leaf node all_nodes([d, e], X) then it returns X = [d, e], is there a way to not return the nodes that were called, even if they are leaves?.
    – user9441470
    Nov 8 at 10:54






  • 1




    Try modifying the findall/4 goal argument to (leaf(Node, Leaf), Node == Leaf).
    – Paulo Moura
    Nov 8 at 10:57










  • It does not work at all with this
    – user9441470
    Nov 8 at 10:59






  • 1




    Yes, it does. Likely you made a typo modifying the findall/4 goal argument. You want findall(Leaf, (leaf(Node, Leaf), Node == Leaf), Leaves, Tail). With this change your get L = for the query all_nodes([d, e], L).
    – Paulo Moura
    Nov 8 at 11:03













up vote
1
down vote



accepted







up vote
1
down vote



accepted






You can take advantage of the de facto standard findall/4 (*) predicate to solve the problem. This predicate is a variant of the standard findall/3 predicate that allows passing a tail for the list of solutions collected by the predicate. For example:



?- findall(N, (N=1; N=2; N=3), L, [4,5]).
L = [1, 2, 3, 4, 5].


In the following solution, I have renamed predicates and variables for clarity and modified your node leaf predicate:



is_a(a, b).
is_a(a, c).

is_a(b, d).
is_a(b, e).

is_a(c, f).
is_a(c, g).

leaf(Leaf, Leaf) :-
+ is_a(Leaf, _).
leaf(Node, Leaf) :-
is_a(Node, Child),
leaf(Child, Leaf).

all_nodes(, ).
all_nodes([Node| Nodes], Leaves):-
findall(Leaf, leaf(Node, Leaf), Leaves, Tail),
all_nodes(Nodes, Tail).


Sample calls:



?- all_nodes([b, c], X).
X = [d, e, f, g].

?- all_nodes([a], X).
X = [d, e, f, g].

?- all_nodes([b], X).
X = [d, e].


(*) It's a built-in predicate in GNU Prolog, JIProlog, Lean Prolog, O-Prolog, SICStus Prolog, SWI-Prolog, XSB, and YAP (possibly others).






share|improve this answer














You can take advantage of the de facto standard findall/4 (*) predicate to solve the problem. This predicate is a variant of the standard findall/3 predicate that allows passing a tail for the list of solutions collected by the predicate. For example:



?- findall(N, (N=1; N=2; N=3), L, [4,5]).
L = [1, 2, 3, 4, 5].


In the following solution, I have renamed predicates and variables for clarity and modified your node leaf predicate:



is_a(a, b).
is_a(a, c).

is_a(b, d).
is_a(b, e).

is_a(c, f).
is_a(c, g).

leaf(Leaf, Leaf) :-
+ is_a(Leaf, _).
leaf(Node, Leaf) :-
is_a(Node, Child),
leaf(Child, Leaf).

all_nodes(, ).
all_nodes([Node| Nodes], Leaves):-
findall(Leaf, leaf(Node, Leaf), Leaves, Tail),
all_nodes(Nodes, Tail).


Sample calls:



?- all_nodes([b, c], X).
X = [d, e, f, g].

?- all_nodes([a], X).
X = [d, e, f, g].

?- all_nodes([b], X).
X = [d, e].


(*) It's a built-in predicate in GNU Prolog, JIProlog, Lean Prolog, O-Prolog, SICStus Prolog, SWI-Prolog, XSB, and YAP (possibly others).







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 8 at 10:28

























answered Nov 8 at 9:31









Paulo Moura

10.6k21325




10.6k21325












  • With this method if I am calling the leaf node all_nodes([d, e], X) then it returns X = [d, e], is there a way to not return the nodes that were called, even if they are leaves?.
    – user9441470
    Nov 8 at 10:54






  • 1




    Try modifying the findall/4 goal argument to (leaf(Node, Leaf), Node == Leaf).
    – Paulo Moura
    Nov 8 at 10:57










  • It does not work at all with this
    – user9441470
    Nov 8 at 10:59






  • 1




    Yes, it does. Likely you made a typo modifying the findall/4 goal argument. You want findall(Leaf, (leaf(Node, Leaf), Node == Leaf), Leaves, Tail). With this change your get L = for the query all_nodes([d, e], L).
    – Paulo Moura
    Nov 8 at 11:03


















  • With this method if I am calling the leaf node all_nodes([d, e], X) then it returns X = [d, e], is there a way to not return the nodes that were called, even if they are leaves?.
    – user9441470
    Nov 8 at 10:54






  • 1




    Try modifying the findall/4 goal argument to (leaf(Node, Leaf), Node == Leaf).
    – Paulo Moura
    Nov 8 at 10:57










  • It does not work at all with this
    – user9441470
    Nov 8 at 10:59






  • 1




    Yes, it does. Likely you made a typo modifying the findall/4 goal argument. You want findall(Leaf, (leaf(Node, Leaf), Node == Leaf), Leaves, Tail). With this change your get L = for the query all_nodes([d, e], L).
    – Paulo Moura
    Nov 8 at 11:03
















With this method if I am calling the leaf node all_nodes([d, e], X) then it returns X = [d, e], is there a way to not return the nodes that were called, even if they are leaves?.
– user9441470
Nov 8 at 10:54




With this method if I am calling the leaf node all_nodes([d, e], X) then it returns X = [d, e], is there a way to not return the nodes that were called, even if they are leaves?.
– user9441470
Nov 8 at 10:54




1




1




Try modifying the findall/4 goal argument to (leaf(Node, Leaf), Node == Leaf).
– Paulo Moura
Nov 8 at 10:57




Try modifying the findall/4 goal argument to (leaf(Node, Leaf), Node == Leaf).
– Paulo Moura
Nov 8 at 10:57












It does not work at all with this
– user9441470
Nov 8 at 10:59




It does not work at all with this
– user9441470
Nov 8 at 10:59




1




1




Yes, it does. Likely you made a typo modifying the findall/4 goal argument. You want findall(Leaf, (leaf(Node, Leaf), Node == Leaf), Leaves, Tail). With this change your get L = for the query all_nodes([d, e], L).
– Paulo Moura
Nov 8 at 11:03




Yes, it does. Likely you made a typo modifying the findall/4 goal argument. You want findall(Leaf, (leaf(Node, Leaf), Node == Leaf), Leaves, Tail). With this change your get L = for the query all_nodes([d, e], L).
– Paulo Moura
Nov 8 at 11:03


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53200160%2fgathering-results-of-methods-in-one-list-with-prolog%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Schultheiß

Liste der Kulturdenkmale in Wilsdruff

Android Play Services Check