I am trying to compute a list that contains the length of each list that are inside a list.
My code is:
length_list(A, B, N) :-
findall(length(Path,E),
path(A, B, Path, Length), N).
path(A, B, [A, B], X) :-
edge(A, B, X).
path(A, B, PathAB, Length) :-
edge(A, C, X),
path(C, B, PathCB, LengthCB),
PathAB = [A | PathCB],
Length is X + LengthCB.
path(A, B, PathAB, Length)
will compute all paths that exist between the point A and the point B and its length
My problem is that my code returns:
?- length_list(a,d,N).
N = [length([a, b, d], _6624),
length([a, b, c, d], _6588),
length([a, b, c, e, d], _6546),
length([a, b, c, e|...], _6498),
length([a, b, c|...], _6456)].
It returns a list of length(Path,E)
but I expected a list of E
.
How can I do that?