Re: Functional syntax
Alan Baljeu <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
> maplist(lambda(Y)\(.(D,x,X), f(X,Y)), List) I was thinking about why this lambda is needed for something as simple as calling. And it occurs to me it isn't. Suppose we define ','/N: (_not_ a1,a2, ,aN) ','(A,B,C) :- call(A), call(B, C). ','(A,B,C,D) :- call(A), call(B, C, D). etc. If this were done, then lambda isn't required. Instead maplist(f(D.x), List) becomes maplist( (dict_lookup(D,x,X), f(X)), List) and maplist may do: call(dict_lookup(D,x,X), f(X)), List_1) which invokes call(dict_lookup(D,x,X), f(X, List1). If you didn't want to overload ',' you can use a different name for the predicate.