> 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:
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
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
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
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
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]
> 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