3 ms·
> effectively amounts to a O(1) lookup So O(log n) then. We obey gravity around these parts. I presume you are referring to HAMT-like structures ,such as foun
by dons 14y ago
> effectively amounts to a O(1) lookup
So O(log n) then. We obey gravity around these parts.
I presume you are referring to HAMT-like structures ,such as found in http://hackage.haskell.org/packages/archive/unordered-containers/0.2.3.0/doc/html/Data-HashMap-Strict.html http://hackage.haskell.org/packages/archive/unordered-contai... which are by no means unique to Clojure.
Besides simply having the data type, you still need a good allocator and GC optimized for immutable data, which is where GHC stands alone - http://benchmarksgame.alioth.debian.org/u32q/benchmark.php?test=all&lang=clojure&lang2=ghc http://benchmarksgame.alioth.debian.org/u32q/benchmark.php?t...
- weavejester 14y ago> So O(log n) then. We obey gravity around these parts. Which is of no practical difference to O(1) if log n is always very small. > I presume you are referring to HAMT-like structures... which are by no means unique to Clojure. Of course they're not. My point was that it is not trivial to derive a efficient and useful data structure like a HAMT from Haskell's type system. The data structures in a library like unordered-containers are in practise just as opaque to the developer as the core data structures in Clojure.
- dons 14y ago> as opaque to the developer http://hackage.haskell.org/packages/archive/unordered-containers/0.2.3.0/doc/html/src/Data-HashMap-Base.html#HashMap http://hackage.haskell.org/packages/archive/unordered-contai... This highly optimized data type is defined in 6 lines, easily accessible from the docs.
- weavejester 14y agoNo it isn't, at least not in any meaningful way. The type definition itself may be 6 lines, but that doesn't adequately describe the data structure, otherwise there'd be no need for the rest of the library.
- lukev 14y agoActually most Clojure maps are Hashtables, which do have O(1) amortized lookup and insert. Granted, the 'amortized' is important.