Thread: Ternary plus
View Single Post
  #6 (permalink)  
Old 02-09-2010, 10:59 PM
Gabriel Genellina
Guest
 
Posts: n/a
Default Re: Ternary plus

En Tue, 09 Feb 2010 15:47:43 -0300, Martin Drautzburg
<Martin.Drautzburg@web.de> escribió:

> Carl Banks wrote:
>
>> You can have __add__ return a closure for the first addition, then
>> perform the operation on the second one. Example (untested):
>>

>
> That's way cool.
>
> <Flash of insight> Of course! - CURRYING!! If you can return closures
> you can do everything with just single-parameter functions.</Flash of
> insight>
>
> BTW I am not really trying to add three objects, I wanted a third object
> which controls the way the addition is done. Sort of like "/" and "//"
> which are two different ways of doing division.


See http://code.activestate.com/recipes/384122/ for another cool hack that
may help with that.

--
Gabriel Genellina

Reply With Quote