【发布时间】:2022-04-13 01:10:22
【问题描述】:
我真的不知道该怎么做,我被要求计算列表中否定的数量,我会提交作业:
let nneg = [4; 9; -5; 0; -5; 1];;
List.filter nneg (fun -> (-))
List.filter nneg (fun x -> x < 0)
但这不是int list -> int,而是int list
所以我开始了这个,但我一生都无法弄清楚如何匹配它:
let rec rev nneg =
match nneg with
| [] -> 0
| head::tail -> (filter tail < 0) head;;
【问题讨论】:
标签: functional-programming ocaml