[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accumulator



Pixel wrote:
> 
>...
> 
> :-(
> 
> i've also read a thread explaining that because of list comprehension,
> map/reduce/filter were more or less deprecated.
> 
> i've yet to see examples where functional programming can be done the
> OO way.

Well I just showed how you can emulate a closure. I guess I don't know
what you mean. And I don't think that there is any occurrence of
map/filter that cannot be replace by a list comprehension (except for
corner cases where Guido decided to use slightly different semantics, in
particular with lists of different lengths). Can you give an example.

> ...IMO this is /somewhat/ orthogonal. And list comprehension are
> another way of writing *some* functional programming, but are really
> limited to lists whereas functional programming is not! (think
> variants)

Once again, can you give an example?

>...
> I understand that having lambda with no closure was the error, which
> is now fixed in python 2.2

It would be too much work to prove that Guido still thinks that lambda
was a mistake but I believe that that is still the case.

> (defclass Acc () ((cur :accessor cur :initarg :start)))
> (defmethod inc ((self Acc) howmuch) (setf (cur self) (+ (cur self) howmuch)))
> (defmethod dec ((self Acc) howmuch) (setf (cur self) (- (cur self) howmuch)))

Great, thanks.

 Paul Prescod