Try typing (type (group-by identity (range 1 50))) into your REPL. You can see that the result is actually a hash map (of class clojure.lang.PersistentHashMap ). This means that it is disordered: in principle, REPL can display a printed letter list in any order of key / value pairs.
The actual reason he printed the printing method is related to the implementation of the Clojure hash map - in terms of data structure, itβs actually a wide tree where each node can have up to 32 children (therefore, the original 32 in your output, recall that Clojure vectors and maps often refer to the cost of searching O (log32N)). This blog article has a good summary.
And no, this does not violate the group-by contract. The contract indicates only the order of the elements of the map elements, and not the order of the card itself.
Daniel Janus
source share