summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2010-02-11 23:27:39 -0500
committerRich Hickey <richhickey@gmail.com>2010-03-11 07:25:18 -0500
commitc97e974c492218609e38a6497b953e38e30b1d83 (patch)
tree3b56f7b49cdc1c811b885f0f0ce6237144305edc
parent5772be9fc5ac9ddf92b727908c20b9aab971224a (diff)
gvec: implement IFn Fixes #265
Signed-off-by: Rich Hickey <richhickey@gmail.com>
-rw-r--r--src/clj/clojure/gvec.clj9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/clj/clojure/gvec.clj b/src/clj/clojure/gvec.clj
index 9e0f0c81..229394b6 100644
--- a/src/clj/clojure/gvec.clj
+++ b/src/clj/clojure/gvec.clj
@@ -204,6 +204,15 @@
(valAt [k] (.valAt this k nil))
+ clojure.lang.IFn
+ (invoke [k]
+ (if (clojure.lang.Util/isInteger k)
+ (let [i (int k)]
+ (if (and (>= i 0) (< i cnt))
+ (.nth this i)
+ (throw (IndexOutOfBoundsException.))))
+ (throw (IllegalArgumentException. "Key must be integer"))))
+
clojure.lang.Seqable
(seq []