I'm trying to create a filter function which recieves a function as parameter and a list and returns another list with the filtering result.
let rec filter bool_func l r =
match l with
| [] -> r
| h::t -> if bool_func h then filter bool_func t (h::r)
else filter bool_func t r in filter bool_func t [];;
The keyword in
goes with a previous let
to make a local definition for use in the expression following in
. So you have a local function definition of filter
followed by the expression filter bool_func t
. And indeed, outside the let
there are no values (that you are showing us) named bool_func
or t
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.