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
> >>> 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
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
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.