我想将级别上的所有节点写入列表。
type 'a tree = T of 'a * 'a tree * 'a tree;;
let at_level t lvl=
let rec aux t k =
match t with
|Leaf -> []
|T(x, l, r) -> if k = lvl then
(x::aux l (k+1)) @ (aux r (k+1))
else
(aux l (k+1)) @( aux r (k+1))
in aux t lvl;;
但我总是收到结果:[x] 其中 x 是根的值。我的程序中的问题在哪里?