reduce()--what is it good for? (was: Re: reduce() anomaly?)

Steve Lamb grey at despair.dmiyu.org
Mon Nov 17 18:57:36 EST 2003


On 2003-11-11, Robin Becker <robin at jessikat.fsnet.co.uk> wrote:
> This whole thread is reminiscent of vi vs emacs or an os war or similar.
> It's a pity that people with a preferred style should be so dogmatic
> that they want to remove language features to prevent others using them.

    The difference there is clear.  vi vs. emacs, OS A vs. OS B are two
completely different entities.  We're talking about the same one here.  That
one has a basic philosophy.

> The whole 'only one way to do it' concept is almost certainly wrong.

    Erm, no.

> There should be maximal freedom to express algorithms. As others have
> stated min, max,... sum et al are useful specialisations, but because
> they cover 99% of the space doesn't mean that reduce is redundant.
> -Eliminate reducespeak and control the future-ly yrs- 

    You have quite a few languages you can do that in.  5+ years in Perl and
I'm done with TIMTOWTDI, thank-you-very-much.  I'm glad that in Python I don't
have to learn several different ways to do the same basic thing.  I lament
every time I have to step into another language which has several ways to do
the same thing and if at any time Python fits the problem space that language
occupies perfectly (as in the case of Perl) then I advocate the hell out of
it.

    I'm glad I no longer have to deal with 4 ways of doing a simple if
statement.  I'm glad that there are only two loop constructs; one for
iterating over a sequence and one that runs until a condition is met.  It
means that at the core level I can read the code and immediately see what is
going on instead of having to memorize a dozen or so specilized ways of doing
things.

    Oddly enough it is in Python that I have had the most fun programming.  It
is in Python that I find myself not only the most expressive but the most
elegant in my programming.  In Python my code is the clearest and most
concise.  I don't for one instant feel constrained by Python.  I feel
liberated by it.

    Because as much as it helps when reading the code to only have to learn a
minimal set of controls the same applies to writing code as well.  When I
approach a problem I don't have to agonize over "well, should I do a
do...until(), a for(;;), a while(), or something else?"  It breaks down to
this.  Is it a sequence?  For.  Is it a condition to be met?  While.  There,
done, move along.

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
       PGP Key: 8B6E99C5       | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------




More information about the Python-list mailing list