[Haskell-cafe] Parse do block problem

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Mon Dec 21 23:20:07 EST 2009

joeltt <joel at harpsoft.com> writes:
>     do_solve_iter guess tried = do
>                 let actual = count_occurences guess
>     if guess == actual
>        then putStrLn "ANSWER!!"
>        else if (find (==actual) tried) == Just actual
>            then do
>                putStrLn "NO ANSWER!"
>                putStrLn tried
>            else do
>                putStrLn "ITER"
>                do_solve_iter actual (actual : tried) 

I think you need to have:

else if (...)
        then ...

(that is, indent the then and else statements)

Better way of doing it: use a case statement, maybe with guards.   

Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com

More information about the Haskell-Cafe mailing list