如何更正此错误?
type 'a drzewo = | Puste | Wezel of 'a * 'a drzewo * 'a drzewo
let rec inorder t =
match t with
| Puste -> print_int (-1)
| Wezel (v, l, r) -> (inorder l; print_int v; inorder r)
let tree =
(1,
(Wezel (2, (Wezel (3, Puste, Puste)),
(Wezel (4, (Wezel (5, Puste, Puste)), Puste)))),
(Wezel (6, Puste, Puste)))
let _ = inorder tree
和错误日志:
最佳答案
问题在这里
let tree =
(1,
(Wezel (2, (Wezel (3, Puste, Puste)),
(Wezel (4, (Wezel (5, Puste, Puste)), Puste)))),
(Wezel (6, Puste, Puste)))
您没有在前面添加
Wezel
。它应该是:
let tree =
Wezel (1,
(Wezel (2, (Wezel (3, Puste, Puste)),
(Wezel (4, (Wezel (5, Puste, Puste)), Puste)))),
(Wezel (6, Puste, Puste)))
关于compiler-errors - OCaml我在哪里出错?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20453778/