Haskell -> Python

Aahz aahz at pythoncraft.com
Sun Nov 4 01:16:30 EDT 2012


In article <b19e3922-d86f-426f-afb8-1f75b793f87b at googlegroups.com>,
 <foster63 at gmail.com> wrote:
>>def options( heaps ):
>> if heaps == []: return []
>> head, tail = heaps[:1], heaps[1:]
>> # Calculate all possible moves which is the sum of 
> # prepending all possible head "moves" to the tail 
> # and appending all possible tail "moves" to the head
>> return [ [h] + tail for h in range( head[0] ) ] \
> + [ head + t for t in options( tail ) ]
>>Is there anything anyone could recommend to make it more "Pythonic" or
>more functional. It looks clumsy next to the Haskell.

If you want more Pythonic, follow PEP8 in your formatting. ;-)
-- 
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"....Normal is what cuts off your sixth finger and your tail..." --Siobhan


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /