From: John Carter Date: 2009-01-16T08:02:10+09:00 Subject: Re: Point free (pointless) programming in ruby? On Wed, 14 Jan 2009, Brian Candler wrote: >> 1) Is there a neater way of expressing a sequence of function >> compositions in Ruby? > > Maybe you could define an Array#to_proc. e.g. > > class Array > def to_proc > lambda { |src| inject(src) { |memo,proc| proc[memo] } } > end > end > p src.map(&[method(:a), method(:b)]) Cool! I had to spend a bit of time rereading the ri docs and playing with irb to work out what you were doing... :-) ...but very cool nevertheless. Ooh.. I bet somebody could... a) Win an obfuscated programming contest... b) Do something very very cool and surprisingly useful.. with the stuff. Basically what I'm seeing here is Ruby is actually a superset of the concatenative languages. If you stick within a strict subset of Ruby you can do the almost magical rewrite algebras that you can do in something like Joy.. http://www.latrobe.edu.au/philosophy/phimvt/joy/j07rrs.html John Carter Phone : (64)(3) 358 6639 Tait Electronics Fax : (64)(3) 359 4632 PO Box 1645 Christchurch Email : john.carter@tait.co.nz New Zealand