Prolog apply predicate to list elements with maplist

356 Views Asked by At

I am trying to do a simple tranformation to all elemnts of a list:

 trans(X, M, Y):- Y is X*(-1) - M.

Then I am writing:

maplist(trans, [1,2,3], NEW). I am getting a just a true instead of a new list..

1

There are 1 best solutions below

0
Luck21 On

Pass a value to parameter like this for example:

maplist(trans(5), [1,2,3], NEW)

Result: NEW = [-6, -7, -8]