[Haskell-cafe] How to do the "permutation and combination" thing?

Magicloud Magiclouds magicloud.magiclouds at gmail.com
Fri Mar 12 01:44:05 EST 2010


All I could get is to use permutations and concatMap. But it looks really ugly.

On Fri, Mar 12, 2010 at 2:09 PM, Casey Hawthorne <caseyh at istar.ca> wrote:
> This sounds like homework.
>
> Think in abstract terms what you want to accomplish.
>
> Start with the simplest case first, usually the base case.
>
>
> On Fri, 12 Mar 2010 14:02:02 +0800, you wrote:
>
>>Hi,
>>  For example, I have this:
>>list1 = [a, b, c]
>>list2 = [d, e, f]
>>list3 = [g, h, i]
>>  Now I want:
>>[ [(a, d, g), (b, e, h), (c, f, i)]
>>, ... ] -- a list that contains all the combinations.
>>  How to do it pretty? Thanks.
> --
> Regards,
> Casey
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
竹密岂妨流水过
山高哪阻野云飞


More information about the Haskell-Cafe mailing list