Normally you would do
foo(..., RV), bar(..,RV,..)
is it possible to create :
$(Term) :- ....
such that writing this :
$foo(...) translates to foo(...,FOO)
so that it becomes from :
$foo(...), bar(..,FOO,..)
to this :sever
foo(..., FOO), bar(..,FOO,..)
?- write_canonical($foo()).
$(foo())
true.
?- write_canonical($foo(abc)).
$(foo(abc))
true.
now that i red the answers … i should not have called for FUNCTION…
what i want is literally what i wrote i.e. create a clause on the fly with a FOO var.
from what i saw…the examples are a way to chain functions…like linux pipe … i want that but i also want to use the VAR across the body i.e. this
foo(…, FOO), bar(…,FOO,…)
but also this :
foo(…, FOO), …more,stuff,in,between,… bar(…,FOO,…)
seems more like a macro to be done at compile time…!! rather than a function