[Haskell-cafe] Re: On the verge of ... giving up!

2007-10-15 Thread apfelmus
[EMAIL PROTECTED] wrote: However, arguably the biggest imperatives for Haskell 98 was to remove features that would confuse undergraduates. [...] People want to write map instead of fmap. We could have come up with an alternative name for the list-version of map and not showed map to newbies.

Re: [Haskell-cafe] Re: On the verge of ... giving up!

2007-10-15 Thread Felipe Lessa
On 10/15/07, apfelmus [EMAIL PROTECTED] wrote: Of course, the solution is to first drop n elements and then take tails instead of dropping n elements every time. map (drop n) . tails = tails . drop n O(m*n) O(m) Nice identity. I'll remember this one. With

Re: [Haskell-cafe] Re: On the verge of ... giving up!

2007-10-15 Thread Daniil Elovkov
2007/10/15, Felipe Lessa [EMAIL PROTECTED]: On 10/15/07, apfelmus [EMAIL PROTECTED] wrote: Of course, the solution is to first drop n elements and then take tails instead of dropping n elements every time. map (drop n) . tails = tails . drop n O(m*n)

[Haskell-cafe] Re: On the verge of ... giving up!

2007-10-15 Thread apfelmus
Felipe Lessa wrote: apfelmus wrote: Of course, the solution is to first drop n elements and then take tails instead of dropping n elements every time. map (drop n) . tails = tails . drop n O(m*n) O(m) Nice identity. I'll remember this one. Oops, please don't

Re: [Haskell-cafe] Re: On the verge of ... giving up!

2007-10-15 Thread Brandon S. Allbery KF8NH
On Oct 15, 2007, at 7:59 , Felipe Lessa wrote: On 10/15/07, apfelmus [EMAIL PROTECTED] wrote: lasts :: Int - [a] - [a] lasts n xs = head $ [x | (x,[]) - zip (tails xs) (tails $ drop n xs)] (...) main n = print . sum . map read . lasts n . lines = getContents But that's a a

[Haskell-cafe] Re: On the verge of ... giving up!

2007-10-14 Thread apfelmus
Vimal wrote: I have been trying my best to read about Haskell from the various tutorials available on the internet and blogs. [...] So, I requested my institute to buy Dr. Graham Hutton's book. I would be getting hold of that quite soon, and am willing to start from the beginning. IMHO, the

[Haskell-cafe] Re: On the verge of ... giving up!

2007-10-14 Thread apfelmus
Brian Hurt wrote: I mean, contemplate this trivial exercise for a moment: write a program that reads from stdin a series of numbers (one number per line), and writes out the sum of the last n numbers. This is a trivial problem, and I have no doubt that someone who knows Haskell better than I

[Haskell-cafe] Re: On the verge of ... giving up!

2007-10-14 Thread Prabhakar Ragde
apfelmus wrote: I mean, contemplate this trivial exercise for a moment: write a program that reads from stdin a series of numbers (one number per line), and writes out the sum of the last n numbers. This is a trivial problem, and I have no doubt that someone who knows Haskell better than

Re: [Haskell-cafe] Re: On the verge of ... giving up!

2007-10-14 Thread Felipe Lessa
On 10/14/07, Prabhakar Ragde [EMAIL PROTECTED] wrote: main n = print . sum . map read . take n . reverse . lines = getContents Could someone describe succinctly how to compute the space complexity of this program, if there are m lines of input and m n? Many thanks. --PR 'reverse' needs to

Re: [Haskell-cafe] Re: On the verge of ... giving up!

2007-10-14 Thread Conal Elliott
More neatly, we can fully separate IO from computation: h n = interact $ show . sum . map read . take n . reverse . lines Better yet go a small step further and make *composable* combinations of IO pure computation, as in TV (http://haskell.org/haskellwiki/TV). Cheers, - Conal On

Re: [Haskell-cafe] Re: On the verge of ... giving up!

2007-10-14 Thread Neil Mitchell
Hi main n = print . sum . map read . take n . reverse . lines = getContents Could someone describe succinctly how to compute the space complexity of this program, if there are m lines of input and m n? Many thanks. --PR The space complexity is the size of the file - i.e. of size m. reverse

[Haskell-cafe] Re: On the verge of ... giving up!

2007-10-14 Thread Chung-chieh Shan
[EMAIL PROTECTED] wrote in article [EMAIL PROTECTED] in gmane.comp.lang.haskell.cafe: That's not my experience. I didn't really understand Kalman filters until I read the Wikipedia page. It's better than most of the tutorials out there. While we're off topic, here's a nice introduction to