0
因此,这是一周的每一天的用户定义的数据类型天(即:周日,周一等)Ocaml程序编写语法效率
let is_weekend_day (d:day) : bool =
begin match d with
| Sunday -> true
| Saturday -> true
| _ -> false
end
有什么办法凝结的代码?如果你想获得看上你可以定义从布尔操作升降机操作员的功能
let is_weekend_day = ListLabels.mem ~set: [Saturday;Sunday];;
:
ie: Sunday || Saturday -> true
the problem with this is that it's not in syntax, but having 2 additional
lines seems like such a waste of space!
你的所有版本后,第一个是效率较低,具有较小的静态检查,你不应该劝他们。 – Drup