列出过滤器,然后在OCaml中列出地图

时间:2018-09-12 05:05:06

标签: list ocaml ocaml-core

如何在OCaml中的列表地图之前应用列表过滤器?我正在尝试管道操作器,但没有成功:

let r infile =
match List.tl (In_channel.read_lines infile ) with
| None -> []
| Some body ->
  List.filter body ~f:(fun line -> true)
  |> List.map body ~f:(fun line ->
    match split_on_comma line with
    | _ :: _ :: num :: street :: unit :: city :: _ :: region :: _ ->
      String.strip (num ^ " " ^ addr_case street ^ ", " ^ addr_case city ^ " " ^ region)
    | _ -> assert false)

utop给我:

“此表达式具有类型字符串列表   但是应该使用字符串列表->'a“

类型的表达式

我知道List.filter目前不执行任何操作。我只是想在List.map之前使用它

0 个答案:

没有答案
相关问题