我希望通过模式匹配后打印字符串列表,以便进入此强大功能。
我应该如何表达“什么也不做但返回单元”的操作?
我的意思是:
let print_nodes nodes =
match nodes with
[] -> (* here i want to noop *)
| s :: t -> print_string s; print_nodes t
我希望通过模式匹配后打印字符串列表,以便进入此强大功能。
我应该如何表达“什么也不做但返回单元”的操作?
我的意思是:
let print_nodes nodes =
match nodes with
[] -> (* here i want to noop *)
| s :: t -> print_string s; print_nodes t
您可以简单地写()
。
请参阅手册中的Variant values: ()
是构建unit
值的方法。