Skip to content

Instantly share code, notes, and snippets.

@konn
Created July 11, 2010 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konn/471520 to your computer and use it in GitHub Desktop.
Save konn/471520 to your computer and use it in GitHub Desktop.
map(Fun, [X|Xs], [X1|Xs1]) :-
!,
Pred =.. [Fun, X, X1],
Pred,
map(Fun, Xs, Xs1).
map(Fun, [], []).
foldl(Fun, X, [Y|Ys], Z) :-
!,
Pred =.. [Fun, X, Y, X1],
Pred,
foldl(Fun, X1, Ys, Z).
foldl(Fun, Z, [], Z).
foldr(Fun, Y, [X|Xs], Z) :-
!,
foldr(Fun, Y, Xs, Y1),
Pred =.. [Fun, X, Y1, Z],
Pred.
foldr(Fun, Z, [], Z).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment