On Feb 27, 2:21 ¨Âí¬ Ôòáî¼ôòáîóæ®®®Àçíáéì®ãïí÷òïôåº > On Feb 16, 8:20 am, Lin Jen-Shin <god... / gmail.com> wrote: > > godfat ~> irb > > irb(main):001:0> require 'rubygems' > > => true > > irb(main):002:0> require 'ludy/proc' > > => true > > irb(main):003:0> lambda{|x,y,z|[x,y,z]}.curry.bind(:_1, 2, :_2)[1,3] > > => [1, 2, 3] > > I suspect you did not need the call to #curry there? Yes, you're right. I forgot to fix my example there (it's just simply copied from rdoc), and later I changed the example to: lambda{|x,y,z|[x,y,z]}.curry.bind(:_1, 2, :_2)[1][3] I found that it didn't work as I expected, [1,2,3] but nil instead. It came from calling [1,2,nil][3]. The curry thing didn't work on bind. I think I would spend some time on fixing this. > Interesting, does it allow .bind(:_1, 2, :_1)[3] ? Yes, it was allowed. The result would be [3,2,3]. Bind just simply creates a lambda which rearranges the arguments for the calling Proc object. > > I am glad to see Proc#curry can be added into core, not supporting > > with library, > > but I didn't see there's Proc#uncurry as well. I hope there's one too. > > Is it a full reversible processes? Yes, it is. See example in Haskell, which make all function default to be curried. I won't explain the example here because this is ruby-core mailing list, neither Haskell nor functional programming. I am very glad to see if more FP stuffs are added into ruby core language. godfat ~> ghci GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude> let func = \x y -> x + y Prelude> func 1 2 3 Prelude> (func 1) 2 3 Prelude> :type func func :: Integer -> Integer -> Integer Prelude> uncurry func (1,2) 3 Prelude> :type uncurry func uncurry func :: (Integer, Integer) -> Integer Prelude> curry (uncurry func) 1 2 3 Prelude> :type curry (uncurry func) curry (uncurry func) :: Integer -> Integer -> Integer > T.