Live data from Hacker News

Data Structures in Clojure: Hash Tables

macromancy.com

11–13 of 13 posts

Re: Data Structures in Clojure: Hash Tables

#11
post #6

Where is the definition of the actual hash function? That is the interesting and tricky part of a hash table. Is "hash" a Clojure built-in?

Clojure has a built-in hash which (I believe) returns the value of .hashCode() [the one java provides].

You are correct, (hash x) returns x.hashCode() from Java http://clojuredocs.org/clojure_core/clojure.core/hash

Re: Data Structures in Clojure: Hash Tables

#12
I love these posts. Even though I'd never use this in production, it's an excellent intro to the same basic data structure taught everywhere. But instead of mucking with a templated C++ implementation (or getting lost in the "plain cons cells for everything!" weeds)... Clojure! It also shows that as much as idiomatic Clojure frowns on OOP and mutability... it's not really that unpleasant to read. I almost want to go through all my old C++ assignments and redo them in Clojure like this.

Re: Data Structures in Clojure: Hash Tables

#13
post #12

I love these posts. Even though I'd never use this in production, it's an excellent intro to the same basic data structure taught everywhere. But instead of mucking with a templated C++ implementation (or getting lost in the "plain cons cells for everything!" weeds)... Clojure! It also shows that as much as idiomatic Clojure frowns on OOP and mutability... it's not really that unpleasant to read. I almost want to go…

Totally agree. Most Clojure code I read is far from easy to jump into for an amateur like myself. It is awesome to see some well-explained and simple code that you can learn from like this.
Post reply on HN