Ocaml 有没有更好的方法来编写这个过滤函数?

Ocaml 有没有更好的方法来编写这个过滤函数?,ocaml,boolean-logic,higher-order-functions,Ocaml,Boolean Logic,Higher Order Functions,我应该创建一个函数,它接受一个列表和一个范围,并过滤列表使其在该数字范围内。以下是我到目前为止的情况: let filter_range (nums : int list) (range : int * int) : int list = match range with | (a, b) -> if a > b then [] else List.filter (fun (x : int) -> if a <= x && x &

我应该创建一个函数,它接受一个列表和一个范围,并过滤列表使其在该数字范围内。以下是我到目前为止的情况:

let filter_range (nums : int list) (range : int * int) : int list =
  match range with
  | (a, b) -> if a > b then []
    else List.filter (fun (x : int) -> 
    if a <= x && x <= b then true else false) nums ;;
let filter_range(nums:int list)(range:int*int):int list=
匹配范围
|(a,b)->如果a>b,则[]
else List.filter(乐趣(x:int)->
如果a在这里:

let filter_range nums (lo, hi) =
  List.filter (fun x -> lo <= x && x <= hi) nums
let filter\u范围nums(低、高)=
List.filter(乐趣x->lo