I am currently using SWI-Prolog to write some code. When I used Prolog years ago I could swear I was able to set variable names to "deconstructions" in the clause head, but it doesn't seem to work correctly for me now (at least in SWI-Prolog).
Toy stupid example:
example(X = [Row|Rows]) :-
do_something_with_x(X),
do_something_with_row(Row),
...
I want to call it as e.g. example( [1,2,3] )
and I want both X
and [Row|Rows]
to be matched against the same predicate's argument, namely the first argument (here, [1,2,3]
), in the predicate's body.
Does anyone know if this is possible?