let rec aux bag pos ctx id = function
| Terms.Leaf _ as t -> f bag t pos ctx id
| Terms.Var _ as t -> bag,t,id
- | Terms.Node l as t->
+ | Terms.Node (hd::l) as t->
let bag,t,id1 = f bag t pos ctx id in
if id = id1 then
let bag, l, _, id =
let bag,newt,id = aux bag newpos newctx id t in
if post = [] then bag, pre@[newt], [], id
else bag, pre @ [newt], List.tl post, id)
- (bag, [], List.tl l, id) l
+ (bag, [hd], List.tl l, id) l
in
bag, Terms.Node l, id
else bag,t,id1
+ | _ -> assert false
in
aux bag pos ctx id t
;;