在Ocaml中将树转换为另一个具有新格式的树

在Ocaml中将树转换为另一个具有新格式的树,ocaml,Ocaml,我想在树上转换为另一棵不同类型的树,大约一周前我尝试了不同的解决方案,但没有成功,请帮助我。 我的代码是: type (a',b') Tree = Lead of a'| Noeud of b'*a'*(a',b')Tree list type strTree = st of int | Leaf of String | Tree of string *Strin* strTree list val Tree-strTree :(a'->string)->(b'->string

我想在树上转换为另一棵不同类型的树,大约一周前我尝试了不同的解决方案,但没有成功,请帮助我。 我的代码是:

type (a',b') Tree = Lead of a'| Noeud of b'*a'*(a',b')Tree list
type strTree = st of int | Leaf of String | Tree of string *Strin* strTree list
val Tree-strTree :(a'->string)->(b'->string)->(a',b')Tree -> strTree

let Tree-strTree p pp a =
   let rec mapA a' = match a' with
     | Lead _ -> Tree ("","",[])
     | Noeud (f,r,l)-> Tree(p f ,pp r ,fold_left(fun x y->x @ [mapA y])[] l)
   in
   mapA  a 
错误:未绑定值向左折叠


我不知道如何使用fold_left

列表
模块中有一个
fold_left
功能。您只需给出模块的名称:

List.fold_left (fun x y -> ... )

但是,正如其他人所指出的,您的代码还存在许多其他问题,至少正如您在这里所展示的那样。

更好地格式化您的代码。每个代码行前面至少有四个空格“但我没有成功”不是一个明确的问题陈述。请看。你的代码也充满了拼写错误。我想说的是,我的代码没有运行,我有错误。请告诉我如何编写我的代码,因为我阻止了这样做,谢谢