I'm trying to write a function which would check, if its elements are alternating.
Example of such a list would be: [1,2,1,2,1,2]
My attempt so far:
fun isAlternating(lst) =
case lst of
[] => true
| x::y::tail => if y <> x
then isAlternating(y::tail)
else false
When I try to test the method it raises the following exception:
uncaught exception Match [nonexhaustive match failure]
It seems I'm missing a pattern, but I don't know which one. Can someone help me with this?