🦙
🦙
prolog findall using nb_setarg/3
##my findall/3
findall(Bindings, Code, ListOut) :- HoldNext=hold(ListOut), %store the tail of the difference list here ( Code, arg(1, HoldNext, Nxt), %var containing the hole to write to Nxt=[Bindings|NewNxt], nb_setarg(1,HoldNext, NewNxt), fail ; arg(1, HoldNext, Nxt), Nxt=[] ).