Hello,
When I write code with => rather than :- as below, looking at the vm code via vm_list, i noticed that quite different code is generated, one making use of i_ssu_commit, and the other of i_cut …
I wonder does the SSU solution create choice points upon encountering the lists in the head of both clauses or not …
My overall objective is to write performant code when for most cases a findall only finds one; and few cases a list of two, and the findall result need to be subsequently processed.
Currently, a first call to to processing predicate with a [First | Rest] which most of the cases leads to a Rest == [] – which then leads to a recursive call of [].
Instead i hope to resolve the one in one call only.
thanks,
Dan
p_list([]) => true.
p_list([Element]) =>
writeln(Element).
p_list([First | Rest]) =>
p_list([First]),
p_list(Rest).
?- p_list([a]).
a
true.
p_list([]).
p_list([Element]) :-
!,
writeln(Element).
p_list([First | Rest]) :-
p_list([First]),
p_list(Rest).