So, I am working on a function that takes two lists already in order from smallest to biggest and merge them in way that they are both sorted. My thinking was to split the second list into head and tail, use insert to sort the head into the first list, and run the function again. However upon running I get:
Couldn't match expected type `[t0]' with actual type `[a0] -> [a0]'
In the return type of a call of `List.insert'
Probable cause: `List.insert' is applied to too few arguments
I am a bit confused as to how I should solve this, here is the code:
combsort((x:xs):(y:ys)) = combsort(List.insert(y (x:xs)) : ys)
combsort((x:xs):[]) = []
You have one set of parentheses too many,
should be
Note that function application doesn’t need parentheses.
In your original, the
List.insert(y (x:xs))is parsed asList.insertapplied to the result of applyingyto the list(x:xs), like