From: Reuben T. <rr...@sc...> - 2004-02-04 21:50:59
|
> > Doesn't matter unless the mapped function is assuming something about the > > underlying list. It shouldn't be. > > Lua isn't a pure language. If map doesn't do what users expect, they will just > go back to their for-loops. Fair enough. And there's another rather more compelling reason: if you're building some kind of result, you want it in order. > > Cos it is. Discussed on the list; look at the code if you're not > > convinced. It's necessary because the table can be rehashed while you're > > traversing it. I think Squirrel avoids this. > > The code below definately runs in O(N), meaning next() is O(1): Once again, I'm talking rubbish. next(t) is linear; next(t,e) is constant time. -- http://www.mupsych.org/~rrt/ motive, n. a mental wolf in moral wool (Bierce) |