Skip to content

Instantly share code, notes, and snippets.

@michaelbarton
Created April 27, 2012 01:05
Show Gist options
  • Save michaelbarton/2504730 to your computer and use it in GitHub Desktop.
Save michaelbarton/2504730 to your computer and use it in GitHub Desktop.
functions = [ [:map, lambda{|x| x * 3}],
[:select, lambda{|x| x % 2 == 0 }],
[:reduce, lambda{|x,y| x + y}] ]
values = [1, 2, 3, 4]
p functions.inject(values){|x,(f,args)| x.send(f,&args) }
#=> 18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment