Re: [Haskell-cafe] Generalized list-comprehension

2004-01-31 Thread Koji Nakahara
> I need to map(\x->otherFunction x) [1..], but this > "next"-function is almost identical to what the > built-in listcomprehension does. > I just don't like my solution. Sorry, I didn't read this. You may prefer something like this to map (\x -> otherFunction x), though mechanical translation:

Re: [Haskell-cafe] Generalized list-comprehension

2004-01-31 Thread Koji Nakahara
Hi, Another solution: f m n = concat $ take m $ tail xs where xs = [[]]:map (\x -> concatMap (\y -> map (y:) x) [1..n]) xs f 3 4 gives your f 4. Hope it helps, Koji Nakahara On Sat, 31 Jan 2004 07:35:38 -0800 (PST) Ron de Bruijn <[EMAIL PROTECTED]> wrote: > Hi there, > > I have wri

Re: [Haskell-cafe] Generalized list-comprehension

2004-01-31 Thread andrew cooke
is this what you want? not sure if i've understood, and not sure it's efficient. andrew grow :: Int -> [[Int]] -> [[Int]] grow n (x:xs) = x:(grow n (xs ++ [x++[i] | i <- [1..n]])) seqn :: Int -> [[Int]] seqn n = grow n [[i] | i <- [1..n]] main :: IO () main = do print $ take 100 (seqn 3) R

Re: [Haskell-cafe] Generalized list-comprehension

2004-01-31 Thread Graham Klyne
There was an exchange about "powerset" here some time ago, before and after this message: http://www.haskell.org/pipermail/haskell-cafe/2003-June/004507.html I think some of the ideas suggested there might be adaptable to this problem: look for sample code with sub-functions for generating co

Re: [Haskell-cafe] Generalized list-comprehension

2004-01-31 Thread Bruno Cesar dos Santos Oliveira
Hello Ron! > Hi there, > > I have written this little function: > > f :: (Num a, Enum a) => a -> [[a]] > f n = [[a]|a<-fu n] ++ [a:[b]|a<-fu n,b<-fu n] ++ > [a:b:[c]|a<-fu n,b<-fu n,c<-fu n] > fu n = [1..n] > > This is an example of the function in action: > > *Mod> f 4 > [[1],[2],[3],[4],[1

[Haskell-cafe] Generalized list-comprehension

2004-01-31 Thread Ron de Bruijn
Hi there, I have written this little function: f :: (Num a, Enum a) => a -> [[a]] f n = [[a]|a<-fu n] ++ [a:[b]|a<-fu n,b<-fu n] ++ [a:b:[c]|a<-fu n,b<-fu n,c<-fu n] fu n = [1..n] This is an example of the function in action: *Mod> f 4 [[1],[2],[3],[4],[1,1],[1,2],[1,3],[1,4],[2,1],[2,2],[2,3]

Re: [Haskell-cafe] Producing fortran/C code with haskell?

2004-01-31 Thread Alastair Reid
> Where could I find information on such topics, or existing libraries to > generate programs with haskell? Is somebody willing to share what (s)he > already did? A possibly useful resource is: My cross-module inliner for C contains a bunch of type definitions to represent C code, a pretty-prin