I'm trying to write a function which gives me the distance between every district in my list. The function distance
gives me the distance between two districts as an Int
from a set array, and I want to run through the whole list to sum up the distance between every district and its follower in the list.
But I'm getting the
Non-exhaustive patterns
error message. What have I overlooked? The function distance
is working as it should.
lengthr :: [district] -> Int
lengthr [] = 0
lengthr (a:b:as) = (distance a b) + lengthr (b:as)