in reply to Combinations of an array of arrays...?
(This is analogous to the Perl solution provided by hv earlier.)combos n ls = filter ((>= n) . length) . map concat . sequence . map (([]:) . map return) $ ls
Examples:
> combos 1 ["abc", "def"] ["d","e","f","a","ad","ae","af","b","bd","be","bf","c","cd","ce","cf"]
Here's the (elided) answer to your example question:
> combos 4 ["abc", "de", "fgh", "i", "jk", "l", "m"] ["ijlm","iklm","fjlm","fklm","film","fijm", ... "cehijlm","cehik","cehikm","cehikl","cehiklm"]
Cheers,
Tom
Tom Moertel : Blog / Talks / CPAN / LectroTest / PXSL / Coffee / Movie Rating Decoder
|
|---|