On Sat, Feb 04, 2006 at 06:31:56PM +0000, Jon Fairbairn wrote: > There ought to be a list_product somewhere (I mean [1..] > `list_product` [4..] == > [(1,4),(2,4),(1,5),(3,4),(2,5),(1,6),...]). Is there?
This is called "fair conjunction" in "Backtracking, Interleaving, and Terminating Monad Transformers" [1]. (>>-) :: [a] -> (a -> [b]) -> [b] [] >>- f = [] (x:xs) >>- f = interleave (f x) (xs >>- f) interleave :: [a] -> [a] -> [a] interleave [] ys = ys interleave (x:xs) ys = x : interleave ys xs t = take 6 ([1..] >>- \x -> [4..] >>- \y -> [(x, y)]) Andrew [1] http://okmij.org/ftp/Computation/monads.html#LogicT _______________________________________________ Haskell-prime mailing list Haskell-prime@haskell.org http://haskell.org/mailman/listinfo/haskell-prime