So I run into some troubles while (ab?)using lambda.pl.
I do a "use_module(library(lambda))." in the first lines of a file that I consult via ["a.prolog"]. Then I get an "undefined procedure ()/3" and some gibberish afterwards.
The same happens for any order of use_modules. It happens whether I load a.prolog via [...], consult or as a script from the cmdline. I reduced the script to the currying-example from Rosseta code https://rosettacode.org/wiki/Currying#Prolog
use_module(library(lambda)).
:- initialization(main, main).
main :-
N = 5, F = \X^Y^(Y is X+N), maplist(F, [1,2,3], L),
print(L).
It doesn't work.
It works, however, if I a manually load 'lambda' at the swipl-prompt and immeditately consult a.prolog. Then the goal N=5,.... works just fine.
If I, however, first consult a.prolog; then manually use_module and then run the query, I get the error. Reconsulting doesn't help onwards.
Somehow, the first command at the prompt needs to be use_module.
Or do I get the loading mechanism completely wrong? If so, please apologize; but I would love get a hint how to solve this.
F_2
in place ofF
. In this manner you are making clear thatF_2
is an incomplete goal that needs two further arguments. – false