2010/10/5 N. Raghavendra <ra...@mri.ernet.in>: > At 2010-10-03T22:45:30+02:00, Dominique Devriese wrote:
>> comma :: (a -> b) -> (a -> c) -> a -> (b,c) >> comma f g x = (f x, g x) >> >> comma = liftA2 (,) >> blowup = (uncurry (++)) . liftA2 (,) (blowup . allButLast) lastToTheLength > > I tried both of them, but they don't seem to work: > > -- Pointfree blowup. > blowup1 :: String -> String > blowup1 = (uncurry (++)) . comma1 (blowup1 . allButLast) lastToTheLength Sorry, I didn't look in detail at your solution in my answer, just focused on the solution, and only checked that it compiled. Your problem is that both your blowup functions recurse infinitely on the empty string (blowup{1,2} [] will always call blowup{1,2} [] again). Instead of fixing it, I recommend you study one of the other solutions proposed in this thread, since they are superior in many ways (shorter, more elegant, more lazy, probably more efficient). cheers Dominique _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe