【发布时间】:2016-05-06 02:52:46
【问题描述】:
当我在 Ocaml 终端“#matrix81 cache;;”上调用时,我的程序出现问题它给了我错误:“此表达式具有类型缓存列表,但此处与类型缓存列表一起使用” 这是我的代码。有什么帮助吗?
let rec makeLine w =
let y = w - 1 in
if w <> 0 then 0::(makeLine y)
else []
;;
let rec makeMatrix w h =
let y = h - 1 in
if h <> 0 then (makeLine w)::(makeMatrix w y)
else []
;;
let rec checkCache lc d t =
match lc with
[] -> 0
|x::xs -> if (x.difficulty = d) && (x.terrain = t) then (checkCache xs d t) + 1
else (checkCache xs d t)
;;
let rec checkLine lc d t line =
match line with
[]->[]
|x::xs -> let nt = t +. 0.5 in
let v = 5.0 in
if (nt < v) then
let nx = (checkCache lc d t) in
(nx)::(checkLine lc d nt xs)
else []
;;
let rec matrix81Aux m d lc =
match m with
[] -> []
|x::xs -> let nd = d +. 0.5 in
let v = 5.0 in
if (nd < v) then
(checkLine lc d 1.0 x)::(matrix81Aux xs nd lc)
else []
;;
let matrix81 lc =
let m = makeMatrix 9 9 in
matrix81Aux m 1.0 lc
;;
【问题讨论】:
-
请不要破坏您的帖子。请注意,一旦您在本网站上发布了问题或答案,这些帖子就会成为也为该内容做出贡献的其他人的集体努力的一部分。除非在特殊情况下,否则不应删除可能对其他人有用的帖子。即使该帖子对原作者不再有用,该信息仍然对将来可能遇到类似问题的其他人有益 - 这是 Stack Exchange 的基本理念。