Ad

Some Picat-like constructs for list comprehension in Prolog.

:- use_module(library(clpfd)).

goal_expansion(R=[Vars:-G|Gs], comprehend_list([Vars:-G|Gs],R)).

comprehend_membership(G) :- 
  G=in(A,[H|T]) -> member(A,[H|T]) 
; G.

comprehend_list(Goal, Bindings) :- findall(X, comprehend(Goal,X), Bindings).
comprehend([Vars :- G|Gs], VarsCp) :- 
  copy_term(Vars-[G|Gs], VarsCp-GsCp),
  maplist(comprehend_membership, GsCp),
  term_variables(VarsCp, Lbls),
  catch(label(Lbls),_,true).

The user defined custom arithmetic function should be visible from plunit.
But then the directive in the .pl Code should be recognized also!
Why won't it allow it?

:- arithmetic_function(double/1).

double(N,M) :- M is N*2.