From: Devin Mullins Date: 2007-03-26T07:47:50+09:00 Subject: Re: Backus, Functional Programming, and Ruby Jesse Merriman wrote: > On Sunday 25 March 2007 18:03, Joel VanderWerf wrote: > >>Ruby has its own way of doing things, not that there is anything wrong >>with defining new ways: >> >>[[1,2,3], [6,5,4]].transpose.map{|x,y|x*y}.inject{|s,x|s+x} >>=> 28 > > Yep, I was just seeing how close I could make Ruby code look like Backus' > code; the goal was to define inner_product as a compose of the three other > functions without any named variables. module Enumerable def inner_product transpose.map(&:*).inject(&:+) end end :P (Not to slight Backus. Functional programming and BNF are both totally cool.)