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