Skip to content
tuples for clojure
Clojure
Find file
Latest commit d61673d Aug 11, 2012 @hiredman snapshot
Failed to load latest commit information.
src/tuples replicate the hashCode algorithm from PV Aug 11, 2012
test/tuples/test Add Object.equals() and Object.hashCode(). Aug 11, 2012
.gitignore init Oct 20, 2011
README.org 0.0.3 Aug 11, 2012
project.clj snapshot Aug 11, 2012

README.org

tuples

Description

Provides “tuples” for Clojure, with faster element access, otherwise behaving like Clojure’s vectors.

Usage

  • add to your project.clj:
[tuples 0.0.3]
;=> (use 'tuples.core)
nil
;=> (tuple 1 2)
[1 2]
;=> (tuple 1 2 3)
[1 2 3]
;=> (tuple 1 2 3 4)
[1 2 3 4]
;=> (tuple 1 2 3 "foo")
[1 2 3 "foo"]
;=> (get0 (tuple 1 2 3 "foo"))
1
;=> (get3 (tuple 1 2 3 "foo"))
"foo"

Performance

;; run on a macbook pro with  java 7 preview
;; Fri Oct 21 12:51:51 2011
tuples.core> (let [n 1e10 t (tuple 1 2) v (vector 1 2)]
               (time (dotimes [_ n] (get0 t)))
               (time (dotimes [_ n] (nth v 0))))
"Elapsed time: 7870.339 msecs"
"Elapsed time: 130419.589 msecs"
nil
tuples.core> 

License

Copyright (C) 2012 Kevin Downey

Distributed under the Eclipse Public License, the same as Clojure.

Something went wrong with that request. Please try again.