Functional Programming
beno
zope at thewebsons.com
Mon Dec 23 09:44:01 EST 2002
At 02:27 PM 12/23/2002 +0100, you wrote:
>beno wrote:
>>Does anyone know of good sources of info for programming using the
>>principles of functional programming in Python? Or, to what languages is
>>Haskell similar? Any other advice on the subject equally welcomed!
>
>You could ask Google:
>
>http://www-106.ibm.com/developerworks/linux/library/l-prog.html
>
>I think most examples from your book would translate literally to Python.
You're right, of course. But I was talking for programming in general.
>A number of mechanisms that people often associate with functional
>programming are not directly available in Python:
>
>- lazy evaluation (arguments are not evaluated if they don't contribute
> to the result). There is no clean way to emulate it in a language that
> does not have it. In some cases, transforming expressions to
> statements (in particular, if-statements) helps. In some cases,
> generators can be used instead.
What about Ty Sarna's and Philip Eby's PEAK?
http://www.telecommunity.com/PEAK/
They use lazy evaluation, and it's all written in Python.
>- tail recursion: while it is available in most languages, it is often
> not eliminated, but can cause stack overflows. You either need to
> rewrite it into a while-loop, or eliminate it from the algorithm
> altogether (e.g. by using map).
>
>- Currying (creating a function from another function by passing some
> arguments): This is not directly available in Python; you can often
> emulate it with lambda expressions.
>
>http://www-106.ibm.com/developerworks/linux/library/l-prog3.html
>
> gives nicer-to-write syntax for that.
Thank you!
beno
More information about the Python-list
mailing list