On 18 February 2013 11:14, Hengqing Hu <hengqing...@gmail.com> wrote: > Though I didn't look into the implementation. > > I suppose length is a constant time operation here, > if you use fold instead to get the same thing. > It would be linear time.
This is not guaranteed. > > Knowing something is empty or not rises after I put something inside > and then take something out. > Then I dont't know whether there are still something left, so I need to > examine it. > Or if something can tell me. Although the point of your algorithm is vague, I believe you will find a better one using hash-fold that does not involve checking for emptiness. Why do you need to know if some elements are left, and what happens if there are? Do you have some code I could look at?