Permalink
Browse files

CLJS-690: add sequence & sorted?

  • Loading branch information...
1 parent 1a8faf5 commit 2a8c2a95fb94feca50413d20fdaf95e7d280a181 @swannodette swannodette committed Dec 3, 2013
Showing with 15 additions and 3 deletions.
  1. +3 −3 devnotes/corelib.org
  2. +12 −0 src/cljs/cljs/core.cljs
View
6 devnotes/corelib.org
@@ -471,7 +471,7 @@ as macro
* DONE seq
* DONE seq?
* seque
-* TODO sequence
+* DONE sequence
* DONE sequential?
* DONE set
* set-error-handler!
@@ -492,7 +492,7 @@ as macro
* DONE sorted-map-by
* DONE sorted-set
* DONE sorted-set-by
-* TODO sorted?
+* DONE sorted?
* DONE special-symbol?
* spit
* DONE split-at
@@ -502,7 +502,7 @@ as macro
* struct
* struct-map
* DONE subs
-* TODO subseq
+* DONE subseq
* DONE subvec
* TODO supers
* DONE swap!
View
12 src/cljs/cljs/core.cljs
@@ -475,6 +475,14 @@
:else (throw (js/Error. (str coll "is not ISeqable"))))))
+(defn ^seq sequence
+ "Coerces coll to a (possibly empty) sequence, if it is not already
+ one. Will not force a lazy seq. (sequence nil) yields ()"
+ [coll]
+ (if (seq? coll)
+ coll
+ (or (seq coll) ())))
+
(defn first
"Returns the first item in the collection. Calls seq on its
argument. If coll is nil, returns nil."
@@ -1120,6 +1128,10 @@ reduces them without incurring seq initialization"
"Returns true if coll satisfies ISequential"
[x] (satisfies? ISequential x))
+(defn ^boolean sorted?
+ "Returns true if coll satisfies ISorted"
+ [x] (satisfies? ISorted x))
+
(defn ^boolean reduceable?
"Returns true if coll satisfies IReduce"
[x] (satisfies? IReduce x))

0 comments on commit 2a8c2a9

Please sign in to comment.