> > > \begin{code} > > catWithLen :: [a] -> (Int -> [a]) -> [a] > > catWithLen xs f = h 0 xs > > where > > h k [] = f k > > h k (x : xs) = case succ k of -- forcing evaluation > > k' -> x : h k' xs > > \end{code} > > > > Thanks but this gives a different problem: > > [EMAIL PROTECTED]:~/sha1> ./allInOne 1000001 +RTS -hc -RTS > [2845392438,1191608682,3124634993,2018558572,2630932637] > [2224569924,473682542,3131984545,4182845925,3846598897] > Stack space overflow: current size 8388608 bytes. > Use `+RTS -Ksize' to increase it.
Does it still do that if you youse seq instead of case? \begin{code} catWithLen :: [a] -> (Int -> [a]) -> [a] catWithLen xs f = h 0 xs where h k [] = f k h k (x : xs) = let k' = succ k in k' `seq` x : h k' xs \end{code} Wolfram _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe