i have list:
[a,b,c]
i want print list this:
a -> b b -> c
so far, have code:
print([]). print([h|t]) :- write(h), write(' -> '), nl, print(t).
which produce following result:
a -> b -> c ->
your predicate needs pull more items out of list. try:
print([]). print([_]). % if we're trying print pairs, can't print single item print([x,y|t]) :- write(x), write(' -> '), write(y), nl, print([y|t]).
Comments
Post a Comment