
1 Feb
2004
1 Feb
'04
6:51 a.m.
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:
xs = [[]]:[[ y:z | y <- [1..n], z <- x] | x <- xs]
Hope it helps,
Koji Nakahara
On Sun, 1 Feb 2004 15:22:01 +0900
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.