attempting to create a list comprehension. What I have here works in SWI Prolog, and also Jekejeke Prolog, but the [ <- ] operator fails in Yap. Unable to figure out why.
Had to create between/3, findall/3, and maplist/2 because they aren't part of Yap. I believe the three homemade predicates work properly (they do in Jekejeke Prolog).
Yap 6.2.2 seems unable to handle the [ <- ] operator. Gets a syntax error immediately preceding the operator.
DEFINE operators:
:- op(700, xfx, [ <- ]).
:- op(450, xfx, [ .. ]).
:- op(1100, yfx, [ & ]).
CREATE a template for list comprehension:
Vs <- M..N :-
integer(M),
integer(N),
M =< N,
betWeen(M, N, Vs).
Vs <- {Var & Dec & Pred} :-
findAll(Var, mapList(call, [Dec, Pred]), Vs).
USE the template to create a list of primes from M through N, inclusive. Return the list as P.
primes(M, N, P) :- P <- { X & X <- M..N & prime(X) }.
END.