Sha256: 4d6d003a0fbe24de5a86e091ab29ed342f5e8c52b74c8ba05e588acfdab2fb4b
Contents?: true
Size: 426 Bytes
Versions: 1
Compression:
Stored size: 426 Bytes
Contents
module Kernel # Composes a list of functions. # Functions can be specified as symbols or lambdas. # ["foo bar", "baz qux"].map &fn(:split, :last) # #=> ["bar", "qux"] # # (1..3).map &fn(:next, -> x { x * x }, -> x { x.to_f / 2 } ) # #=> [2.0, 4.5, 8.0] def fn(*funs) #:doc: -> x do funs.inject(x) do |v,f| Proc === f ? f.call(v) : v.send(f) end end end private :fn end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shenanigans-1.0.13 | lib/shenanigans/kernel/fn.rb |