Sha256: 5ba3233bd6f6f5116fd1e85fdf700586e342da037af81177d0aa7c48b34d765e
Contents?: true
Size: 419 Bytes
Versions: 3
Compression:
Stored size: 419 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) -> 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shenanigans-1.0.11 | lib/shenanigans/kernel/fn.rb |
shenanigans-1.0.10 | lib/shenanigans/kernel/fn.rb |
shenanigans-1.0.9 | lib/shenanigans/kernel/fn.rb |