我必须计算二维 (2D) 列表 [[Int]] 中的出现次数,但出现错误。
我这样做是为了计算一维。它像这样工作正常:
instances::Int->[Int]->Int
instances x [] = 0
instances x (y:ys)
| x==y = 1+(instances x ys)
| otherwise = instances x ys
您能否帮我修改此功能以计算 2D 列表:
instances::Int->[Int]->Int
提前致谢