Re: Question regarding Higher-Order-Programming in Python

2010-12-22 Thread Arnaud Delobelle
Mark Fink writes: > so far I have never noticed chain.from_iterable, but many thanks to > you Peter, I have now a beautiful solution to this problem. from itertools import chain comb = it.combinations(dims, 2) l = chain.from_iterable(it.imap(get_products, comb)) You can also write

Re: Question regarding Higher-Order-Programming in Python

2010-12-22 Thread Mark Fink
> >>> list(chain.from_iterable(starmap(product, izip(izip(dims.iterkeys()), > > dims.itervalues() > [('special', '+'), ('special', '-'), ('number', 1), ('number', 2), > ('number', 3), ('letter', 'a'), ('letter', 'b')] > > Peter so far I have never noticed chain.from_iterable, but many thanks t

Re: Question regarding Higher-Order-Programming in Python

2010-12-22 Thread Peter Otten
Mark Fink wrote: > I am about to learn Higher-Order-Programming with Lisp, Haskell, and > Python. Some people who have gone completely out of their mind call > this FP. > > In Haskell I learned that when I use map on a list it starts nesting > as soon as I start adding elements. If I do not like

Question regarding Higher-Order-Programming in Python

2010-12-22 Thread Mark Fink
I am about to learn Higher-Order-Programming with Lisp, Haskell, and Python. Some people who have gone completely out of their mind call this FP. In Haskell I learned that when I use map on a list it starts nesting as soon as I start adding elements. If I do not like the nesting I use ConcatMap.