
25 Oct
2012
25 Oct
'12
5:41 p.m.
On Fri, Oct 26, 2012 at 12:44:31AM +0400, dokondr wrote:
I am looking for the algorithm and code better then the one I wrote (please Build all possible element combinations from N lists. Valid combination consists of k <= N elements. Where each element of a single combination is taken from one of the N lists.
combos [] = [[]] combos ([]:ls) = combos ls combos ((h:t):ls) = map (h:) (combos ls) ++ combos (t:ls) Drop last element if you don't want to include the empty set. It wouldn't be as elegant, but you can translate this to Java. Alex