Check if the list is ascending (Haskell) -
i writing function check if tree if bst. i've tried print tree in in-order traversal list , check if list increasing. having error:
couldn't match expected type `a' against inferred type `[t]' `a' rigid type variable bound type signature `checklist' @ bst.hs:24:18 in pattern: x : y : xs in pattern: [x : y : xs] in definition of `checklist': checklist [x : y : xs] = x <= y && checklist (y : xs)
here have far (only checklist function).
checklist :: (ord a) => [a] -> bool checklist [] = true checklist [x] = true checklist [x:y:xs] = x <= y && checklist (y:xs)
you want:
checklist :: (ord a) => [a] -> bool checklist [] = true checklist [x] = true checklist (x:y:xs) = x <= y && checklist (y:xs)
when tried use [ ]
in final pattern, saying "match against list contains x:y:xs
(also list!) sole element". doesn't match type [a]
.
Comments
Post a Comment