/* maplist1( List,F,NewList) if NewList contains the result of applying
the function F (represented by a binary relation <domain,range>) to each
entry of NewList, in order. */

maplist1( [],_,[]).

maplist1( [ X|Tail],F,[ NewX|NewTail]) :-
  G =.. [ F,X,NewX],
  G,        % some Prologs require call( G) instead of G
  maplist1( Tail,F,NewTail).

/* Square function, for example query
   ?- maplist1( [2,6,5],square,Squares) */
square( X,Y) :- Y is X*X.
