Skip to content

Instantly share code, notes, and snippets.

@zonuexe
Created September 11, 2011 15:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zonuexe/1209698 to your computer and use it in GitHub Desktop.
Save zonuexe/1209698 to your computer and use it in GitHub Desktop.
Rubyでカリー化函数
curry = ->(f){
args = []
return rec = ->(a){
args << a
return f.call(*args) if (args.length == f.arity) || (f.arity == -1)
return rec
}
}
if __FILE__ == $0
func = ->(a,b,c){ a * b * c }
puts func[1,2,3]
puts curry[func][1][2][3]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment