Currently SWI-Prolog does not support (=)/2 in the head of (=>)/2. I get:
?- [user].
|: foo(bar)=baz => true.
ERROR: user://1:8:
ERROR: No permission to modify static procedure `(=)/2'
But I guess Picat would allow (See 1.3 Defining Functions in the
user manual of Picat) the same, and then treat it as follows I guess:
foo(bar, X) => X = baz.
Allowing this function syntax would allow to write many examples more consciese.
jan
February 17, 2021, 8:03am
7
j4n_bur53:
Is there a solution for meta-interpreters and single sided unification?
See previous discussion on what is now rule/2,3 and how this could be (and probably will be) extended.
Is it useful to have a bidirectional reverse/2? I think this suffices (a straightforward translation of library(lists) reverse/2, using =>
):
reverse(List, Reversed) =>
reverse(List, [], Reversed, Reversed).
reverse([], Ys, Reversed, Tail) =>
Reversed = Ys,
Tail = [].
reverse([X|Xs], Rs, Reversed, Tail) =>
Tail = [_|Bound],
reverse(Xs, [X|Rs], Reversed, Bound).
j4n_bur53:
Doesn’t work on my side.
I thought that the intent was to raise an exception if reverse/2 has an uninstantiated first argument. If you want to handle an uninstantiated first argument (although I don’t know why this would be wanted), you could just wrap reverse/4 with a freeze/2 or when/2.