Jump to content

First-class functions: Difference between revisions

m
→‎{{header|Ruby}}: Line 9 is now line 6.
(→‎{{header|Ruby}}: Skip Method#to_proc, because Method#[] works as well as Proc#[]. Shorten input lines, never exceed 80 characters for input lines (but an output line is 81 characters).)
m (→‎{{header|Ruby}}: Line 9 is now line 6.)
Line 1,141:
irb(main):005:0> invlist = [Math.method(:asin), Math.method(:acos), croot]
=> [#<Method: Math.asin>, #<Method: Math.acos>, #<Proc:0x00000201f6a6c8@(irb):2>]
irb(main):009006:0> funclist.zip(invlist).map {|f, invf| compose[invf, f][0.5]}
=> [0.5, 0.4999999999999999, 0.5]</lang>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.