Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Currying/Ruby/currying.rb
Normal file
13
Task/Currying/Ruby/currying.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
b = proc {|x, y, z| (x||0) + (y||0) + (z||0) }
|
||||
p b.curry[1][2][3] #=> 6
|
||||
p b.curry[1, 2][3, 4] #=> 6
|
||||
p b.curry(5)[1][2][3][4][5] #=> 6
|
||||
p b.curry(5)[1, 2][3, 4][5] #=> 6
|
||||
p b.curry(1)[1] #=> 1
|
||||
|
||||
b = proc {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.inject(0, &:+) }
|
||||
p b.curry[1][2][3] #=> 6
|
||||
p b.curry[1, 2][3, 4] #=> 10
|
||||
p b.curry(5)[1][2][3][4][5] #=> 15
|
||||
p b.curry(5)[1, 2][3, 4][5] #=> 15
|
||||
p b.curry(1)[1] #=> 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue