Last active
November 22, 2017 02:55
-
-
Save xandkar/3deed1716ff35848bd1c to your computer and use it in GitHub Desktop.
Automatic currying in Erlang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(curry). | |
-export([curry/1]). | |
curry(F) -> | |
{arity, Arity} = erlang:fun_info(F, arity), | |
curry(F, [], Arity). | |
curry(F, Args, 0) -> | |
apply(F, lists:reverse(Args)); | |
curry(F, Args, Arity) -> | |
fun (X) -> curry(F, [X | Args], Arity - 1) end. |
Author
xandkar
commented
Apr 28, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment