File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 985
985
(assert (= (hash {:start 133 :end 134 })
986
986
(hash (apply hash-map [:start 133 :end 134 ]))))
987
987
988
+ (defprotocol IHasFirst
989
+ (-get-first [this]))
990
+
991
+ (defprotocol IFindsFirst
992
+ (-find-first [this other]))
993
+
994
+ (deftype First [xs]
995
+ ISeqable
996
+ (-seq [this] (seq xs))
997
+ IIndexed
998
+ (-nth [this i] (nth xs i))
999
+ (-nth [this i not-found] (nth xs i not-found))
1000
+ IFn
1001
+ (-invoke [[x]] x)
1002
+ Object
1003
+ (toString [[x]] (str x))
1004
+ IHasFirst
1005
+ (-get-first [[x]] x)
1006
+ IFindsFirst
1007
+ (-find-first [_ [x]] x))
1008
+
1009
+ (let [fv (First. [1 2 3 ])
1010
+ fs (First. " asdf" )]
1011
+ (assert (= (fv ) 1 ))
1012
+ (assert (= (fs ) \a))
1013
+ (assert (= (str fs) \a))
1014
+ (assert (= (-get-first fv) 1 ))
1015
+ (assert (= (-get-first fs) \a))
1016
+ (assert (= (-find-first fv [1 ]) 1 )))
1017
+
988
1018
:ok
989
1019
)
You can’t perform that action at this time.
0 commit comments