Re: [Haskell-cafe] Building all possible element combinations from N lists.

2012-10-28 Thread dokondr
On Fri, Oct 26, 2012 at 2:34 AM, Jake McArthur jake.mcart...@gmail.comwrote: I golfed a bit. :) sequence = filterM (const [False ..]) What is golfed and = ? Please, explain. Thanks, Dmitri ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Building all possible element combinations from N lists.

2012-10-28 Thread Clark Gaebel
Golfed: http://en.wikipedia.org/wiki/Code_golf = : Also known as Kleisli composition. More info: http://www.haskell.org/hoogle/?hoogle=%3C%3D%3C On Sun, Oct 28, 2012 at 4:36 PM, dokondr doko...@gmail.com wrote: On Fri, Oct 26, 2012 at 2:34 AM, Jake McArthur jake.mcart...@gmail.comwrote: I

[Haskell-cafe] Building all possible element combinations from N lists.

2012-10-25 Thread dokondr
Hi all, I am looking for the algorithm and code better then the one I wrote (please see below) to solve the problem given in the subject. Unfortunately I finally need to implement this algorithm in Java. That's why I am not only interested in beautiful Haskell algorithms, but also in the one that

Re: [Haskell-cafe] Building all possible element combinations from N lists.

2012-10-25 Thread Alex Stangl
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

Re: [Haskell-cafe] Building all possible element combinations from N lists.

2012-10-25 Thread dokondr
On Fri, Oct 26, 2012 Alex Stangl wrote: * * combos [] = [[]] combos ([]:ls) = combos ls combos ((h:t):ls) = map (h:) (combos ls) ++ combos (t:ls) Excellent, thanks! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Building all possible element combinations from N lists.

2012-10-25 Thread Jake McArthur
I golfed a bit. :) sequence = filterM (const [False ..]) On Thu, Oct 25, 2012 at 6:11 PM, dokondr doko...@gmail.com wrote: On Fri, Oct 26, 2012 Alex Stangl wrote: combos [] = [[]] combos ([]:ls) = combos ls combos ((h:t):ls) = map (h:) (combos ls) ++ combos (t:ls) Excellent,

Re: [Haskell-cafe] Building all possible element combinations from N lists.

2012-10-25 Thread Alex Stangl
On Thu, Oct 25, 2012 at 06:34:53PM -0400, Jake McArthur wrote: I golfed a bit. :) sequence = filterM (const [False ..]) I was thinking of golfing this myself tonight, but probably wouldn't have come up with this. Thanks for sparing me the effort. Bravo! Alex