9 Nov
2011
9 Nov
'11
5:17 p.m.
I forgot to mention that this definition: saturation (_,edges,_) = length $ foldr (\ed ac -> colors!ed : ac) [] edges is working too. I don't understand why the version with an 'if' is not working. Best Regards, Karol Samborski 2011/11/9 Karol Samborski <edv.karol@gmail.com>:
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