
Thanks Felipe Lessa for shortening the code :) and everyone for advice.
I have recently started learning haskell from the book
Learnyouahaskell - www.learnyouahaskell.com - I am done with the book except
for Bytestreams and randomness. Was trying to put my haskell skills to use
on the problems of this kind. My aim is to understand and practice haskell
and not WIN these code golf competitions! . So, please suggest me what are
the other books i can read ( and work through :) ), in general any good open
source projects to involve in, etc.. basically any advices to improve as a
haskell programmer.
Thanks in advance.
On Wed, Jun 30, 2010 at 9:50 AM, Lyndon Maydwell
I agree. If you're aiming for really terse code, have a look at the J/K languages. These seem to win most golf-shootout type competitions. Haskell is more focused on expressiveness and abstraction.
On Wed, Jun 30, 2010 at 11:25 AM, Michael Mossey
wrote: rizwan hudda wrote:
I have recently started learning haskell, and was trying to write a code for this problem http://www.spoj.pl/problems/KAMIL in haskell. The aim
is to
write a shortest possible code for the given task. I have previously solved this in c,c++,perl,python.My best was 57 characters using perl. So here's my code in HASKELL:
main = interact $ unlines. map (show.foldl (\a x-> if null $ filter (==x) "TDLF" then a else a+a) 1) .lines
It is 107 characters [ non white space and newline ]. I was interested in knowing how i could further optimize the size of this code.
This kind of contest is fun, but I can't help thinking I hope you are learning Haskell to appreciate the things that functional programming is good at. Real-world Haskell is often more concise than other languages because Haskell has mechanisms for eliminating unnecessary and redundant code, but Haskell's strength is not winning "shortest program" contests.
Mike _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- Thanks and regards Rizwan A Hudda http://sites.google.com/site/rizwanhudda