I have this code to filter list of string that the first letter is capital:
fun f s = Char.isUpper(String.sub(s,0));
fun only_capitals (xs : string list) = List.filter(f , xs);
But when compile, I always receive error :
operator domain: 'Z -> bool
operand: (string -> bool) * string list
in expression:
List.filter (f,xs)
I don't know how to fix this. Can tell me, what does this error mean, and how to fix this.
Thanks :)
Type signature of List.filter
is
val filter : ('a -> bool) -> 'a list -> 'a list
So you need to give List.filter
two distinct arguments, not one argument which happens to be a tuple.