bernd.holzmueller at ics-ag.de
Tue Jun 6 08:06:52 EDT 2006
This should do:
combinations :: [[a]] -> [[a]]
combinations  = []
combinations [[x]] = [[x]]
combinations ( : xxs) = combinations xxs
combinations ((h : tl) : xxs) = [h : r | r <- combinations xxs] ++
if null tl then  else combinations (tl : xxs)
developer at imaginando.net schrieb:
> I need a functions which takes as argument a list of lists like this one:
> and gives me a list of list with all the possible combinations like this one:
> In this case there are only 2 combinations but if there was more than one
> element in the other lists the results were much more.
> I'm a little stuck in this simple problem.
> First i was thinking in cartesian product but then i realized that i may
> not be what i really need.
> Any tip?
> Many thx,
> Nuno Santos
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
Tel.: +49 (0) 711 / 2 10 37 - 643
Fax: +49 (0) 711 / 2 10 37 - 653
Mobile: +49 (0) 151 / 17449 534
mailto:bernd.holzmueller at ics-ag.de
More information about the Haskell-Cafe