Created
February 10, 2012 03:24
-
-
Save swannodette/1786095 to your computer and use it in GitHub Desktop.
array.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(extend-type array | |
ISeqable | |
(-seq [array] (array-seq array 0)) | |
ICounted | |
(-count [a] (.-length a)) | |
IIndexed | |
(-nth | |
([array n] | |
(if (< n (.-length array)) (aget array n))) | |
([array n not-found] | |
(if (< n (.-length array)) (aget array n) | |
not-found))) | |
ILookup | |
(-lookup | |
([array k] | |
(aget array k)) | |
([array k not-found] | |
(-nth array k not-found))) | |
IReduce | |
(-reduce | |
([array f] | |
(ci-reduce array f)) | |
([array f start] | |
(ci-reduce array f start)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment