[Haskell-beginners] Question about problem "KAMIL" from SPOJ

Frerich Raabe raabe at froglogic.com
Thu Jul 18 18:17:39 CEST 2013


On 2013-07-18 17:32, Nadav Chernin wrote:
> My second solution was:
>
> main=getLine>>=print.(2^).length.filter(`elem`"TDLF")>>main
>
> This code = 60 bytes, but i get Run-Time error on SPOJ
>
> I don't understand how this code can create RTE?

I think it's because getLine will try to read something even if you're 
at the end of the input. Try guarding the call with 'isEOF', e.g.

   main=isEOF>>=flip 
unless(getLine>>=print.(2^).length.filter(`elem`"TDLF")>>main)

-- 
Frerich Raabe - raabe at froglogic.com
www.froglogic.com - Multi-Platform GUI Testing




More information about the Beginners mailing list