Can this be written more concisely in a functional style

Ben Finney bignose-hates-spam at and-benfinney-does-too.id.au
Mon Nov 17 19:39:33 EST 2003


On 18 Nov 2003 11:28:09 +1050, Ben Finney wrote:
> On 17 Nov 2003 16:48:36 -0800, MetalOne wrote:
>> def f(xs):
>>     for x in xs:
>>         if test(x): return True
>>     return False
>
> If you want to hide the algorithm, do so inside a helper function.
> Then you have consision in the places where you're actually using it,
> and explicit semantics where the algorithm is implemented.

On second look, you appear to *be* putting this in a helper function,
presumably for the purpose of hiding the implementation.  If so, it's a
good thing that the implementation is explicit here -- anyone who goes
looking into this function wants it obvious how it works.

-- 
 \          "When I get real bored, I like to drive downtown and get a |
  `\         great parking spot, then sit in my car and count how many |
_o__)                 people ask me if I'm leaving."  -- Steven Wright |
Ben Finney <http://bignose.squidly.org/>




More information about the Python-list mailing list