我真的被困在如何去做这件事上,我被要求计算列表中否定的数量,我会提交作业:
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;;