Re: [Haskell-cafe] Re: Suggestions for improvement

2010-10-05 Thread Dominique Devriese
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

[Haskell-cafe] Re: Suggestions for improvement

2010-10-04 Thread N. Raghavendra
At 2010-10-03T13:49:34-07:00, Gregory Crosswhite wrote: It is worth noting that such a function already exists in the standard libraries; it is the operator in Control.Arrow: blowup = uncurry (++) . (blowup . allButLast lastToTheLength) Thanks for that. More reading material!

[Haskell-cafe] Re: Suggestions for improvement

2010-10-04 Thread N. Raghavendra
At 2010-10-04T01:52:05+04:00, Victor Nazarov wrote: I suggest to pay more attention to haskell's standard library. allButLast is called init in Data.List module. Thanks for that. I should keep printouts of the Prelude handy. Second, do not use explicit recursion. You can capture recursion

[Haskell-cafe] Re: Suggestions for improvement

2010-10-04 Thread N. Raghavendra
At 2010-10-03T20:03:22-04:00, wren ng thornton wrote: And just to play a little Haskell golf: lastToTheLength = ap (flip map) (const . last) Thanks for that. Regards, Raghavendra. -- N. Raghavendra ra...@mri.ernet.in | http://www.retrotexts.net/ Harish-Chandra Research Institute |

[Haskell-cafe] Re: Suggestions for improvement

2010-10-04 Thread N. Raghavendra
At 2010-10-05T09:21:51+13:00, Richard O'Keefe wrote: answer s = concat $ zipWith replicate [1..] s I looked at the examples and said, hmm, elements are being repeated varying numbers of times. Looked up repeat, found that that was the wrong function, and saw replicate, which is the right

[Haskell-cafe] Re: Suggestions for improvement

2010-10-04 Thread N. Raghavendra
At 2010-10-03T22:45:30+02:00, Dominique Devriese wrote: You need a function like the following for that: comma :: (a - b) - (a - c) - a - (b,c) comma f g x = (f x, g x) Then you could say: blowup = (uncurry (++)) . comma (blowup . allButLast) lastToTheLength Ignore this if you haven't

[Haskell-cafe] Re: Suggestions for improvement

2010-10-03 Thread N. Raghavendra
At 2010-10-03T22:45:30+02:00, Dominique Devriese wrote: Additionally, you can't combine the functions (blowup . allButLast) and lastToTheLength into a function that returns a pair like you seem to attempt. You need a function like the following for that: comma :: (a - b) - (a - c) - a -