Functions in ML can only take one argument. Description from here (see also notes and videos).
List.filter is a so-called curry function, so List.filter f xs is actually (List.filter f) xs , where List.filter f is a function. We should provide f (fn: a -> bool) as an argument to List.filter , not tuple (f, xs) .
Here is a simple example. When we call is_sorted 1 , we get a closure with x in our environment. When we call this closure with 2, we get true because 1 <= 2 .
val is_sorted = fn x => (fn y => x <= y) val test0 = (is_sorted 1) 2 val is_sorted = fn : int -> int -> bool val test0 = true : bool
source share