[Haskell-beginners] Problem with an if statement

Karol Samborski edv.karol at gmail.com
Wed Nov 9 10:04:03 CET 2011


Hi,

With a function defined like this (colors is type of Array Int [Int]
and edges is [Int]):
saturation (_,edges,_) = foldr (\ed ac ->if null (colors!ed) then ac
else ac+1) 0 edges
I'm getting an infinite loop.

But when I remove the if statement like this:
saturation (_,edges,_) = foldr (\ed ac -> ac+1) 0 edges
everything's working.

How should I define my function with the if statement to not getting
an infinite loop?

Best Regards,
Karol Samborski



More information about the Beginners mailing list