Ocaml树。我有这部分代码:[(aux(c+;1)l)@(aux(c+;1)r)]

Ocaml树。我有这部分代码:[(aux(c+;1)l)@(aux(c+;1)r)],ocaml,Ocaml,有人能告诉我这个代码在我的程序中做什么吗? (辅(c+1)l)@(辅(c+1)r) 以下是所有代码: let rec aux c = function Empty -> [] |Tr(x,l,r) -> let l = (aux (c+1) l)@(aux (c+1) r) in if c = n then x::l else l in aux 1 tr;; 您遗漏了一些定义n和tr的上下文。我还要说,你的问题很

有人能告诉我这个代码在我的程序中做什么吗? (辅(c+1)l)@(辅(c+1)r)

以下是所有代码:

 let rec aux c = function
   Empty -> []
    |Tr(x,l,r) ->
     let l =
      (aux (c+1) l)@(aux (c+1) r) in
       if c = n then x::l else l
         in aux 1 tr;;

您遗漏了一些定义
n
tr
的上下文。我还要说,你的问题很模糊。一般来说,您提到的表达式从树的更深处获取值列表。它用
@
运算符将两个列表连接起来。

是的,代码如下:键入'a tree=Empty'Tr of'a*'a tree*'a tree;;设f n tr=let rec aux c=function Empty->[]|tr(x,l,r)->设l=(aux(c+1)l)@(aux(c+1)r)in如果c=n那么x::l else l in aux 1 tr;;