type 'a prelist = { mutable start : 'a list; mutable current : 'a list} let start () = { start = []; current = []} let cons a pl = match pl.current with [] -> let l = [a] in pl.current <- l; pl.start <- l | l -> let l' = [a] in Obj.set_field (Obj.repr l) 1 (Obj.repr l'); pl.current <- l' let extract pl = let r = pl.start in pl.current <- []; pl.start <- []; (* to guaranty that we can not mute the list once it has been extracted *) r