Newbie: finding the key/index of the min/max element

Alex Martelli aleax at aleax.it
Thu May 2 09:52:38 EDT 2002


On Thursday 02 May 2002 03:25 pm, James J. Besemer wrote:
	...
> > >> Since seq.index(max(seq)) is most concise, fastest, and quite clear,
> >
> > Functional Programming is indeed an elegant paradigm, but it's not the
> > one being used here -- no higher-order functions, etc.  Or maybe you
> > mean something else by FP (Floating Point?  naah...).
>
> EEEEKKKK!!!!  SARCASM!!!!   RUN AWAY!! RUN AWAY!!  ;o)
>
> Seriously, I respectfully and humbly beg to differ...
>
> (a) I thought I was using the term consistently with others in posts
> earlier, when we were talking about map() and filter().

Those ARE higher-order functions, you know.


> (b) To me FP fundamentally is actually little more than tending towards
> expressions instead of statements.  And this is consistent with the
> comp.lang.FP Faq
>
>     (http://www.cs.nott.ac.uk/~gmh//faq.html)
>
> Typically for it to be FP the operands are not scalars but vectors or more

Ah, APL, the ultimate functional programming language!  Sorry, but that
FAQ's response seems rather inapplicable to me here.  Just because
you're calling an ordinary function or two (even on vectors) doesn't mean
your overall style "emphasizes the evaluation of expressions, rather than
the execution of commands".  Were I do define FP, I'd focus on 'immutable
data' (or 'single assignment' as being roughly equivalent).  Thus ruling APL
out because, while STRONGLY expression-oriented (and vector, too!),
its typical expressions most often include the <- (leftarrow) operator which,
surprise surprise, assigns data.

> complex objects that may be thought to "flow" from one operator to the
> next. Higher order functions are included in the broader topic but they're
> not necessary to perform basic FP tasks.

You may choose to define "basic FP tasks" as being those which require
neither data mutation or name rebinding, nor higher-order functions.  Not
a very large set, to be sure, but still it would apply to e.g. all pure string
manipulations in Python -- still, IMHO, too wide a set for usefully sharp
definition.


Alex





More information about the Python-list mailing list