home
/
code
/
hope.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
Implement automatic currying.
[hope.git]
/
src
/
hope_fun.erl
1
-module(hope_fun).
2
3
-export(
4
[ id/1
5
, curry/1
6
]).
7
8
-spec id(A) ->
9
A.
10
id(X) ->
11
X.
12
13
-spec curry(fun()) ->
14
fun().
15
curry(F) ->
16
{value, {arity, Arity}} = lists:keysearch(arity, 1, erlang:fun_info(F)),
17
curry(F, [], Arity).
18
19
-spec curry(fun(), list(), integer()) ->
20
fun().
21
curry(F, Args, 0) ->
22
apply(F, lists:reverse(Args));
23
curry(F, Args, Arity) ->
24
fun (X) -> curry(F, [X | Args], Arity - 1) end.
This page took
0.063214 seconds
and
4
git commands to generate.