From: Joel VanderWerf Date: 2005-12-15T11:43:08+09:00 Subject: Re: LISP to Ruby translation Douglas Livingstone wrote: > Jut a quick one, how do you translate this: > > ((if (zero? 0) + -) 3 4) > => 7 > > to Ruby? > > Cheers, > Douglas > 3.send(x.zero? ? :+ : :-, 4) It's a little hard to read with all those colons. Maybe this is better: 3.send(if x.zero? then :+ else :- end, 4) Or you could replace symbols with strings for readability, at a cost to speed: p 3.send(x.zero? ? "+" : "-", 4) -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407