I'm trying to write a function in SML to flip alternate elements of a list. Here's my function:
fun flipAlternate(nil) = nil
| flipAlternate([x]) = x
| flipAlternate(x::y::xs) = y::x::flipAlternate(xs);
When I go to use my file (Ullman.sml) in the interactive interpreter, I get this compilation error:
- use "Ullman.sml";
[opening Ullman.sml]
Ullman.sml:5.31-5.54 Error: operator and operand don't agree [circularity]
operator domain: 'Z list * 'Z list list
operand: 'Z list * 'Z list
in expression:
x :: flipAlternate xs
So SML is saying it requires a list of lists of integers but I'm only giving it a pair of lists of integers?
I'm a bit lost here so any help would be much appreciated.
Thanks, bclayman