如何在OCaml中做"noop但返回单位"

Jac*_*ack 13 ocaml pattern-matching no-op

我想在完成模式匹配之后打印一个字符串列表,以进入这个强大的功能.

如何表达"无所事事但返回单位"的操作?

我的意思是:

let print_nodes nodes =
  match nodes with
      []     -> (* here i want to noop *)
    | s :: t -> print_string s; print_nodes t
Run Code Online (Sandbox Code Playgroud)

ton*_*nio 24

你可以简单地写().

请参阅手册中的变体值:()是如何构建unit值的.