From: Brian H. <bh...@sp...> - 2003-04-18 22:13:22
|
In my ongoing quest to remove all but one Obj.magic calls from ExtList, I propose the following implementation for ExtList.of_enum: let of_enum e = try let h = [ Enum.next e ] in let _ = Enum.fold (fun x acc -> let r = [ x ] in _setcdr acc r; r) h e in h with Enum.No_more_elements -> [] (I have tabstop set to 4 currently. That's a different argument.) This depends upon the exported Enum.next patch. Basically, if the enum is empty creating the head element throws a caught exception and returns [], otherwise we go on to the classic fold implementation. Brian |