functional programming
Aahz Maruch
aahz at netcom.com
Tue Feb 22 12:23:00 EST 2000
In article <Pine.GSO.4.20_heb2.08.0002221713320.20007-100000 at sundial>,
Moshe Zadka <mzadka at geocities.com> wrote:
>
>Functional programming has a very clear definition: no side
>effects. Iterating explicitly means "with side effects." I'm not saying
>one style is better then the other, but you *can't* program functionally
>in Python. I had to get over it, and learn to write fibonaci with a while
>loop, when I first got to Python.
<blink><blink> What do you call this:
def fib(x):
if x != int(x):
raise "Must use an integer"
if x < 0:
raise "Must be > 0"
if x == 0 or x == 1:
return 1L
else:
return fib(x-1) + fib(x-2)
(apologies for any errors, but I think this is basically correct)
--
--- Aahz (Copyright 2000 by aahz at netcom.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
Love does not conquer all. Humans are extremely flexible, usually more
flexible than we're willing to admit. But some flexibility comes at a
cost, and sometimes that cost is more than we can bear.
More information about the Python-list
mailing list