In article ,
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
Ian Kelly wrote:
> On Fri, Nov 2, 2012 at 1:19 PM, wrote:
>> Is there anything anyone could recommend to make it more "Pythonic"
>> or more functional. It looks clumsy next to the Haskell.
>
> def options(heaps):
> for i, heap in enumerate(heaps):
> head = heaps[:i]
> tai
On 11/02/2012 06:27 PM, Ian Kelly wrote:
> On Fri, Nov 2, 2012 at 4:24 PM, Dave Angel wrote:
>> Perhaps range(heap) should be replaced by range(len(heap))
> "heaps" is a list of ints per the OP, so "heap" is an int.
You're right of course . I was distracted by the fact that a
heap is normally a
On Fri, Nov 2, 2012 at 4:24 PM, Dave Angel wrote:
> Perhaps range(heap) should be replaced by range(len(heap))
"heaps" is a list of ints per the OP, so "heap" is an int.
--
http://mail.python.org/mailman/listinfo/python-list
On 11/02/2012 05:40 PM, Ian Kelly wrote:
> On Fri, Nov 2, 2012 at 1:19 PM, wrote:
>> Is there anything anyone could recommend to make it more "Pythonic" or more
>> functional. It looks clumsy next to the Haskell.
> def options(heaps):
> for i, heap in enumerate(heaps):
> head = heap
On Fri, Nov 2, 2012 at 3:40 PM, Ian Kelly wrote:
> On Fri, Nov 2, 2012 at 1:19 PM, wrote:
>> Is there anything anyone could recommend to make it more "Pythonic" or more
>> functional. It looks clumsy next to the Haskell.
>
> def options(heaps):
> for i, heap in enumerate(heaps):
>
On Fri, Nov 2, 2012 at 1:19 PM, wrote:
> Is there anything anyone could recommend to make it more "Pythonic" or more
> functional. It looks clumsy next to the Haskell.
def options(heaps):
for i, heap in enumerate(heaps):
head = heaps[:i]
tail = heaps[i+1:]
yield fro
On 02/11/12 19:56, Dave Angel wrote:
On 11/02/2012 03:19 PM, foste...@gmail.com wrote:
Hi All,
As part of a Nim solver I'm playing around with I'm trying to code this Haskell
snippet:
options [x] = zero : [ [y] | y <- [1..x - 1] ]
options (x:xs) = map (++ xs) (options [x]) ++ map (x:) (
On 11/02/2012 03:19 PM, foste...@gmail.com wrote:
> Hi All,
>
> As part of a Nim solver I'm playing around with I'm trying to code this
> Haskell snippet:
>
> options [x] = zero : [ [y] | y <- [1..x - 1] ]
> options (x:xs) = map (++ xs) (options [x]) ++ map (x:) (options xs)
>
> in Python. So
Hi All,
As part of a Nim solver I'm playing around with I'm trying to code this Haskell
snippet:
options [x] = zero : [ [y] | y <- [1..x - 1] ]
options (x:xs) = map (++ xs) (options [x]) ++ map (x:) (options xs)
in Python. So far I have this, which works OK, but somehow doesn't feel right
10 matches
Mail list logo