[Haskell-beginners] best way to code this~~

briand at aracnet.com briand at aracnet.com
Wed Jun 3 04:53:04 UTC 2015


On Tue, 02 Jun 2015 15:49:06 +0000
Alex Hammel <ahammel87 at gmail.com> wrote:


> My version looks like it traverses the list twice, but it doesn't because
> laziness. Where the compiler for a strict language might make an
> intermediate, uppercased list, Haskell will produce the uppercase values as
> they are needed.

ok that's cool to know.  that's why i like going over these "simple" examples.

in thinking about my problem i realized that it's perfectly fine if the uneaten list comes back upper case. so i went back to the map version. actually the list comp version :-)

> 
> Incidentally, that's the same reason why the `filterMap` function you asked
> about earlier doesn't exist. You can just do `(map f . filter p) xs`. The
> values will be created lazily, with no intermediate list.

precisely what i was wondering.
haven't tried out criterion yet, just installed it to try out.

seems like a valuable learning tool.

should be a good learning tool.


Brian



More information about the Beginners mailing list