triska
searching PlanetScale…
- 1.▲
- 2.▲
- 3.▲
- 4.▲
- 5.▲
- 6.▲
68 ms·
- 511.▲
- 512.▲
Yes, that's also possible with this definition! For example: Given Ls0 = [a,b,c] and Ls = [a,c], which element (if any) was dropped: ?- drop(X, [a,b,c], [a,c]).
X = b ;
false.
As another example, if both Ls0 and Ls a - 513.▲
To illustrate how close Erlang syntax is to Prolog, here is drop/3 in Prolog: drop(X, List, Result) :- drop(X, List, [], Result).
drop(_, [], Acc, Result) :- reverse(Acc, Result).
drop(X, [X|Rest], Acc, Result) :- drop(X - 514.▲
- 515.▲
- 516.▲
- 517.▲