Hi everyone,
I'm trying to write a function that takes in a list and returns true if it is in sorted order and false if not:
So far what I have is:
myordered [] = True
myordered [x] = True
myordered list1
| (head list1) <= (head (tail list1)) = myordered(tail list1)
| otherwise = False
Based on our assignment, all head and tail operations should be written down as "x:xs" type syntax.
the translation I come up with for the section with a guard is:
myordered y:x:xs
| (y) <= (x) = myordered(xs)
| otherwise = False
Essentially this question boils down to: How do you express the (head (tail list1)) in "x:xs" type syntax?
Cheers, -Zigu