News for hackers. Stuff that matters.
Re:Clojure, Faster by brundolf on Friday January 08, 2021 @06:04PM (#25691668)
You wouldn't want to use iterators to compute the length of a collection, even in a language where they're fast. That turns a constant-time operation into a linear-time operation
Re:Clojure, Faster by patrec on Saturday January 09, 2021 @07:12AM (#25699715)
Not true, with two random access iterators in C++ for example you can compute the distance between them, and thus the the length of an array (e.g. a.end() - a.begin()) and it will be constant time.
Re:Clojure, Faster by brundolf on Sunday January 10, 2021 @12:09PM (#25716757)
I guess I'm not familiar enough with C++'s iterators. In most languages I'm familiar with, an iterator is an abstract concept that only knows how to get the next item and (sometimes) tell whether or not it's finished.