summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStuart Halloway <stu@thinkrelevance.com>2010-04-29 18:48:50 -0400
committerStuart Halloway <stu@thinkrelevance.com>2010-05-03 16:06:02 -0400
commit59b65669860a1f33825775494809e5d500c19c63 (patch)
tree4ff16f1966e4d8debc7b32d6191ba3793d48d15d /src
parent7b4b8e18c0d28e03e7c66f54bc441ef355ceb5ed (diff)
added 1.0, test all public doc-ed fns have :added
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
Diffstat (limited to 'src')
-rw-r--r--src/clj/clojure/core.clj785
-rw-r--r--src/clj/clojure/core_print.clj12
-rw-r--r--src/clj/clojure/core_proxy.clj12
-rw-r--r--src/clj/clojure/genclass.clj3
-rw-r--r--src/clj/clojure/gvec.clj3
-rw-r--r--src/clj/clojure/inspector.clj3
-rw-r--r--src/clj/clojure/set.clj10
-rw-r--r--src/clj/clojure/test.clj1
-rw-r--r--src/clj/clojure/xml.clj1
-rw-r--r--src/clj/clojure/zip.clj30
10 files changed, 674 insertions, 186 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index 6b0fbbbf..2ee14a07 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -15,56 +15,65 @@
(def
^{:arglists '([& items])
- :doc "Creates a new list containing the items."}
+ :doc "Creates a new list containing the items."
+ :added "1.0"}
list (. clojure.lang.PersistentList creator))
(def
^{:arglists '([x seq])
:doc "Returns a new seq where x is the first element and seq is
- the rest."}
+ the rest."
+ :added "1.0"}
cons (fn* cons [x seq] (. clojure.lang.RT (cons x seq))))
;during bootstrap we don't have destructuring let, loop or fn, will redefine later
(def
- ^{:macro true}
+ ^{:macro true
+ :added "1.0"}
let (fn* let [&form &env & decl] (cons 'let* decl)))
(def
- ^{:macro true}
+ ^{:macro true
+ :added "1.0"}
loop (fn* loop [&form &env & decl] (cons 'loop* decl)))
(def
- ^{:macro true}
+ ^{:macro true
+ :added "1.0"}
fn (fn* fn [&form &env & decl]
(.withMeta ^clojure.lang.IObj (cons 'fn* decl)
(.meta ^clojure.lang.IMeta &form))))
(def
^{:arglists '([coll])
- :doc "Returns the first item in the collection. Calls seq on its
- argument. If coll is nil, returns nil."}
+ :doc "Returns the first item in the collection. Calls seq on its
+ argument. If coll is nil, returns nil."
+ :added "1.0"}
first (fn first [coll] (. clojure.lang.RT (first coll))))
(def
^{:arglists '([coll])
- :tag clojure.lang.ISeq
- :doc "Returns a seq of the items after the first. Calls seq on its
- argument. If there are no more items, returns nil."}
+ :tag clojure.lang.ISeq
+ :doc "Returns a seq of the items after the first. Calls seq on its
+ argument. If there are no more items, returns nil."
+ :added "1.0"}
next (fn next [x] (. clojure.lang.RT (next x))))
(def
^{:arglists '([coll])
- :tag clojure.lang.ISeq
- :doc "Returns a possibly empty seq of the items after the first. Calls seq on its
- argument."}
+ :tag clojure.lang.ISeq
+ :doc "Returns a possibly empty seq of the items after the first. Calls seq on its
+ argument."
+ :added "1.0"}
rest (fn rest [x] (. clojure.lang.RT (more x))))
(def
^{:arglists '([coll x] [coll x & xs])
- :doc "conj[oin]. Returns a new collection with the xs
+ :doc "conj[oin]. Returns a new collection with the xs
'added'. (conj nil item) returns (item). The 'addition' may
- happen at different 'places' depending on the concrete type."}
+ happen at different 'places' depending on the concrete type."
+ :added "1.0"}
conj (fn conj
([coll x] (. clojure.lang.RT (conj coll x)))
([coll x & xs]
@@ -74,75 +83,88 @@
(def
^{:doc "Same as (first (next x))"
- :arglists '([x])}
+ :arglists '([x])
+ :added "1.0"}
second (fn second [x] (first (next x))))
(def
^{:doc "Same as (first (first x))"
- :arglists '([x])}
+ :arglists '([x])
+ :added "1.0"}
ffirst (fn ffirst [x] (first (first x))))
(def
^{:doc "Same as (next (first x))"
- :arglists '([x])}
+ :arglists '([x])
+ :added "1.0"}
nfirst (fn nfirst [x] (next (first x))))
(def
^{:doc "Same as (first (next x))"
- :arglists '([x])}
+ :arglists '([x])
+ :added "1.0"}
fnext (fn fnext [x] (first (next x))))
(def
^{:doc "Same as (next (next x))"
- :arglists '([x])}
+ :arglists '([x])
+ :added "1.0"}
nnext (fn nnext [x] (next (next x))))
(def
^{:arglists '([coll])
- :doc "Returns a seq on the collection. If the collection is
+ :doc "Returns a seq on the collection. If the collection is
empty, returns nil. (seq nil) returns nil. seq also works on
Strings, native Java arrays (of reference types) and any objects
that implement Iterable."
- :tag clojure.lang.ISeq}
+ :tag clojure.lang.ISeq
+ :added "1.0"}
seq (fn seq [coll] (. clojure.lang.RT (seq coll))))
(def
^{:arglists '([^Class c x])
- :doc "Evaluates x and tests if it is an instance of the class
- c. Returns true or false"}
+ :doc "Evaluates x and tests if it is an instance of the class
+ c. Returns true or false"
+ :added "1.0"}
instance? (fn instance? [^Class c x] (. c (isInstance x))))
(def
^{:arglists '([x])
- :doc "Return true if x implements ISeq"}
+ :doc "Return true if x implements ISeq"
+ :added "1.0"}
seq? (fn seq? [x] (instance? clojure.lang.ISeq x)))
(def
^{:arglists '([x])
- :doc "Return true if x is a Character"}
+ :doc "Return true if x is a Character"
+ :added "1.0"}
char? (fn char? [x] (instance? Character x)))
(def
^{:arglists '([x])
- :doc "Return true if x is a String"}
+ :doc "Return true if x is a String"
+ :added "1.0"}
string? (fn string? [x] (instance? String x)))
(def
^{:arglists '([x])
- :doc "Return true if x implements IPersistentMap"}
+ :doc "Return true if x implements IPersistentMap"
+ :added "1.0"}
map? (fn map? [x] (instance? clojure.lang.IPersistentMap x)))
(def
^{:arglists '([x])
- :doc "Return true if x implements IPersistentVector "}
+ :doc "Return true if x implements IPersistentVector"
+ :added "1.0"}
vector? (fn vector? [x] (instance? clojure.lang.IPersistentVector x)))
(def
^{:arglists '([map key val] [map key val & kvs])
- :doc "assoc[iate]. When applied to a map, returns a new map of the
+ :doc "assoc[iate]. When applied to a map, returns a new map of the
same (hashed/sorted) type, that contains the mapping of key(s) to
val(s). When applied to a vector, returns a new vector that
- contains val at index. Note - index must be <= (count vector)."}
+ contains val at index. Note - index must be <= (count vector)."
+ :added "1.0"}
assoc
(fn assoc
([map key val] (. clojure.lang.RT (assoc map key val)))
@@ -155,15 +177,17 @@
;;;;;;;;;;;;;;;;; metadata ;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def
^{:arglists '([obj])
- :doc "Returns the metadata of obj, returns nil if there is no metadata."}
+ :doc "Returns the metadata of obj, returns nil if there is no metadata."
+ :added "1.0"}
meta (fn meta [x]
(if (instance? clojure.lang.IMeta x)
(. ^clojure.lang.IMeta x (meta)))))
(def
^{:arglists '([^clojure.lang.IObj obj m])
- :doc "Returns an object of the same type and value as obj, with
- map m as its metadata."}
+ :doc "Returns an object of the same type and value as obj, with
+ map m as its metadata."
+ :added "1.0"}
with-meta (fn with-meta [^clojure.lang.IObj x m]
(. x (withMeta m))))
@@ -194,7 +218,8 @@
(def
^{:arglists '([coll])
- :doc "Return the last item in coll, in linear time"}
+ :doc "Return the last item in coll, in linear time"
+ :added "1.0"}
last (fn last [s]
(if (next s)
(recur (next s))
@@ -202,7 +227,8 @@
(def
^{:arglists '([coll])
- :doc "Return a seq of all but the last item in coll, in linear time"}
+ :doc "Return a seq of all but the last item in coll, in linear time"
+ :added "1.0"}
butlast (fn butlast [s]
(loop [ret [] s s]
(if (next s)
@@ -214,8 +240,9 @@
^{:doc "Same as (def name (fn [params* ] exprs*)) or (def
name (fn ([params* ] exprs*)+)) with any doc-string or attrs added
to the var metadata"
- :arglists '([name doc-string? attr-map? [params*] body]
- [name doc-string? attr-map? ([params*] body)+ attr-map?])}
+ :arglists '([name doc-string? attr-map? [params*] body]
+ [name doc-string? attr-map? ([params*] body)+ attr-map?])
+ :added "1.0"}
defn (fn defn [&form &env name & fdecl]
(let [m (if (string? (first fdecl))
{:doc (first fdecl)}
@@ -256,17 +283,20 @@
(defn cast
"Throws a ClassCastException if x is not a c, else returns x."
+ {:added "1.0"}
[^Class c x]
(. c (cast x)))
(defn to-array
"Returns an array of Objects containing the contents of coll, which
can be any Collection. Maps to java.util.Collection.toArray()."
- {:tag "[Ljava.lang.Object;"}
+ {:tag "[Ljava.lang.Object;"
+ :added "1.0"}
[coll] (. clojure.lang.RT (toArray coll)))
(defn vector
"Creates a new vector containing the args."
+ {:added "1.0"}
([] [])
([a] [a])
([a b] [a b])
@@ -277,6 +307,7 @@
(defn vec
"Creates a new vector containing the contents of coll."
+ {:added "1.0"}
([coll]
(if (instance? java.util.Collection coll)
(clojure.lang.LazilyPersistentVector/create coll)
@@ -285,12 +316,14 @@
(defn hash-map
"keyval => key val
Returns a new hash map with supplied mappings."
+ {:added "1.0"}
([] {})
([& keyvals]
(. clojure.lang.PersistentHashMap (createWithCheck keyvals))))
(defn hash-set
"Returns a new hash set with supplied keys."
+ {:added "1.0"}
([] #{})
([& keys]
(clojure.lang.PersistentHashSet/createWithCheck keys)))
@@ -298,17 +331,20 @@
(defn sorted-map
"keyval => key val
Returns a new sorted map with supplied mappings."
+ {:added "1.0"}
([& keyvals]
(clojure.lang.PersistentTreeMap/create keyvals)))
(defn sorted-map-by
"keyval => key val
Returns a new sorted map with supplied mappings, using the supplied comparator."
+ {:added "1.0"}
([comparator & keyvals]
(clojure.lang.PersistentTreeMap/create comparator keyvals)))
(defn sorted-set
"Returns a new sorted set with supplied keys."
+ {:added "1.0"}
([& keys]
(clojure.lang.PersistentTreeSet/create keys)))
@@ -322,7 +358,8 @@
;;;;;;;;;;;;;;;;;;;;
(defn nil?
"Returns true if x is nil, false otherwise."
- {:tag Boolean}
+ {:tag Boolean
+ :added "1.0"}
[x] (clojure.lang.Util/identical x nil))
(def
@@ -330,8 +367,9 @@
^{:doc "Like defn, but the resulting function name is declared as a
macro and will be used as a macro by the compiler when it is
called."
- :arglists '([name doc-string? attr-map? [params*] body]
- [name doc-string? attr-map? ([params*] body)+ attr-map?])}
+ :arglists '([name doc-string? attr-map? [params*] body]
+ [name doc-string? attr-map? ([params*] body)+ attr-map?])
+ :added "1.0"}
defmacro (fn [&form &env
name & args]
(let [prefix (loop [p (list name) args args]
@@ -375,34 +413,40 @@
(defmacro when
"Evaluates test. If logical true, evaluates body in an implicit do."
+ {:added "1.0"}
[test & body]
(list 'if test (cons 'do body)))
(defmacro when-not
"Evaluates test. If logical false, evaluates body in an implicit do."
+ {:added "1.0"}
[test & body]
(list 'if test nil (cons 'do body)))
(defn false?
"Returns true if x is the value false, false otherwise."
- {:tag Boolean}
+ {:tag Boolean,
+ :added "1.0"}
[x] (clojure.lang.Util/identical x false))
(defn true?
"Returns true if x is the value true, false otherwise."
- {:tag Boolean}
+ {:tag Boolean,
+ :added "1.0"}
[x] (clojure.lang.Util/identical x true))
(defn not
"Returns true if x is logical false, false otherwise."
- {:tag Boolean}
+ {:tag Boolean
+ :added "1.0"}
[x] (if x false true))
(defn str
"With no args, returns the empty string. With one arg x, returns
x.toString(). (str nil) returns the empty string. With more than
one arg, returns the concatenation of the str values of the args."
- {:tag String}
+ {:tag String
+ :added "1.0"}
([] "")
([^Object x]
(if (nil? x) "" (. x (toString))))
@@ -416,15 +460,18 @@
(defn symbol?
"Return true if x is a Symbol"
+ {:added "1.0"}
[x] (instance? clojure.lang.Symbol x))
(defn keyword?
"Return true if x is a Keyword"
+ {:added "1.0"}
[x] (instance? clojure.lang.Keyword x))
(defn symbol
"Returns a Symbol with the given namespace and name."
- {:tag clojure.lang.Symbol}
+ {:tag clojure.lang.Symbol
+ :added "1.0"}
([name] (if (symbol? name) name (clojure.lang.Symbol/intern name)))
([ns name] (clojure.lang.Symbol/intern ns name)))
@@ -432,6 +479,7 @@
"Returns a new symbol with a unique name. If a prefix string is
supplied, the name is prefix# where # is some unique number. If
prefix is not supplied, the prefix is 'G__'."
+ {:added "1.0"}
([] (gensym "G__"))
([prefix-string] (. clojure.lang.Symbol (intern (str prefix-string (str (. clojure.lang.RT (nextID))))))))
@@ -440,6 +488,7 @@
time. If a test returns logical true, cond evaluates and returns
the value of the corresponding expr and doesn't evaluate any of the
other tests or exprs. (cond) returns nil."
+ {:added "1.0"}
[& clauses]
(when clauses
(list 'if (first clauses)
@@ -452,7 +501,8 @@
(defn keyword
"Returns a Keyword with the given namespace and name. Do not use :
in the keyword strings, it will be added automatically."
- {:tag clojure.lang.Keyword}
+ {:tag clojure.lang.Keyword
+ :added "1.0"}
([name] (cond (keyword? name) name
(symbol? name) (clojure.lang.Keyword/intern ^clojure.lang.Symbol name)
(string? name) (clojure.lang.Keyword/intern ^String name)))
@@ -469,6 +519,7 @@
(defn list*
"Creates a new list containing the items prepended to the rest, the
last of which will be treated as a sequence."
+ {:added "1.0"}
([args] (seq args))
([a args] (cons a args))
([a b args] (cons a (cons b args)))
@@ -478,7 +529,8 @@
(defn apply
"Applies fn f to the argument list formed by prepending args to argseq."
- {:arglists '([f args* argseq])}
+ {:arglists '([f args* argseq])
+ :added "1.0"}
([^clojure.lang.IFn f args]
(. f (applyTo (seq args))))
([^clojure.lang.IFn f x args]
@@ -493,6 +545,7 @@
(defn vary-meta
"Returns an object of the same type and value as obj, with
(apply f (meta obj) args) as its metadata."
+ {:added "1.0"}
[obj f & args]
(with-meta obj (apply f (meta obj) args)))
@@ -500,7 +553,8 @@
"Takes a body of expressions that returns an ISeq or nil, and yields
a Seqable object that will invoke the body only the first time seq
is called, and will cache the result and return it on all subsequent
- seq calls."
+ seq calls."
+ {:added "1.0"}
[& body]
(list 'new 'clojure.lang.LazySeq (list* '^{:once true} fn* [] body)))
@@ -532,6 +586,7 @@
(defn concat
"Returns a lazy seq representing the concatenation of the elements in the supplied colls."
+ {:added "1.0"}
([] (lazy-seq nil))
([x] (lazy-seq x))
([x y]
@@ -560,21 +615,25 @@
"Takes a body of expressions and yields a Delay object that will
invoke the body only the first time it is forced (with force or deref/@), and
will cache the result and return it on all subsequent force
- calls."
+ calls."
+ {:added "1.0"}
[& body]
(list 'new 'clojure.lang.Delay (list* `^{:once true} fn* [] body)))
(defn delay?
"returns true if x is a Delay created with delay"
+ {:added "1.0"}
[x] (instance? clojure.lang.Delay x))
(defn force
"If x is a Delay, returns the (possibly cached) value of its expression, else returns x"
+ {:added "1.0"}
[x] (. clojure.lang.Delay (force x)))
(defmacro if-not
"Evaluates test. If logical false, evaluates and returns then expr,
otherwise else expr, if supplied, else nil."
+ {:added "1.0"}
([test then] `(if-not ~test ~then nil))
([test then else]
`(if (not ~test) ~then ~else)))
@@ -583,7 +642,8 @@
"Tests if 2 arguments are the same object"
{:tag Boolean
:inline (fn [x y] `(. clojure.lang.Util identical ~x ~y))
- :inline-arities #{2}}
+ :inline-arities #{2}
+ :added "1.0"}
([x y] (clojure.lang.Util/identical x y)))
(defn =
@@ -594,7 +654,8 @@
comparison."
{:tag Boolean
:inline (fn [x y] `(. clojure.lang.Util equiv ~x ~y))
- :inline-arities #{2}}
+ :inline-arities #{2}
+ :added "1.0"}
([x] true)
([x y] (clojure.lang.Util/equiv x y))
([x y & more]
@@ -606,7 +667,8 @@
(defn not=
"Same as (not (= obj1 obj2))"
- {:tag Boolean}
+ {:tag Boolean
+ :added "1.0"}
([x] false)
([x y] (not (= x y)))
([x y & more]
@@ -621,7 +683,8 @@
compares numbers and collections in a type-independent manner. x
must implement Comparable"
{:tag Integer
- :inline (fn [x y] `(. clojure.lang.Util compare ~x ~y))}
+ :inline (fn [x y] `(. clojure.lang.Util compare ~x ~y))
+ :added "1.0"}
[x y] (. clojure.lang.Util (compare x y)))
(defmacro and
@@ -629,6 +692,7 @@
returns logical false (nil or false), and returns that value and
doesn't evaluate any of the other expressions, otherwise it returns
the value of the last expr. (and) returns true."
+ {:added "1.0"}
([] true)
([x] x)
([x & next]
@@ -640,6 +704,7 @@
returns a logical true value, or returns that value and doesn't
evaluate any of the other expressions, otherwise it returns the
value of the last expression. (or) returns nil."
+ {:added "1.0"}
([] nil)
([x] x)
([x & next]
@@ -650,20 +715,23 @@
(defn zero?
"Returns true if num is zero, else false"
{:tag Boolean
- :inline (fn [x] `(. clojure.lang.Numbers (isZero ~x)))}
+ :inline (fn [x] `(. clojure.lang.Numbers (isZero ~x)))
+ :added "1.0"}
[x] (. clojure.lang.Numbers (isZero x)))
(defn count
"Returns the number of items in the collection. (count nil) returns
0. Also works on strings, arrays, and Java Collections and Maps"
{:tag Integer
- :inline (fn [x] `(. clojure.lang.RT (count ~x)))}
+ :inline (fn [x] `(. clojure.lang.RT (count ~x)))
+ :added "1.0"}
[coll] (clojure.lang.RT/count coll))
(defn int
"Coerce to int"
{:tag Integer
- :inline (fn [x] `(. clojure.lang.RT (intCast ~x)))}
+ :inline (fn [x] `(. clojure.lang.RT (intCast ~x)))
+ :added "1.0"}
[x] (. clojure.lang.RT (intCast x)))
(defn nth
@@ -672,7 +740,8 @@
also works for strings, Java arrays, regex Matchers and Lists, and,
in O(n) time, for sequences."
{:inline (fn [c i & nf] `(. clojure.lang.RT (nth ~c ~i ~@nf)))
- :inline-arities #{2 3}}
+ :inline-arities #{2 3}
+ :added "1.0"}
([coll index] (. clojure.lang.RT (nth coll index)))
([coll index not-found] (. clojure.lang.RT (nth coll index not-found))))
@@ -680,7 +749,8 @@
"Returns non-nil if nums are in monotonically increasing order,
otherwise false."
{:inline (fn [x y] `(. clojure.lang.Numbers (lt ~x ~y)))
- :inline-arities #{2}}
+ :inline-arities #{2}
+ :added "1.0"}
([x] true)
([x y] (. clojure.lang.Numbers (lt x y)))
([x y & more]
@@ -692,7 +762,8 @@
(defn inc
"Returns a number one greater than num."
- {:inline (fn [x] `(. clojure.lang.Numbers (inc ~x)))}
+ {:inline (fn [x] `(. clojure.lang.Numbers (inc ~x)))
+ :added "1.0"}
[x] (. clojure.lang.Numbers (inc x)))
;; reduce is defined again later after InternalReduce loads
@@ -714,6 +785,7 @@
(defn reverse
"Returns a seq of the items in coll in reverse order. Not lazy."
+ {:added "1.0"}
[coll]
(reduce conj () coll))
@@ -721,7 +793,8 @@
(defn +
"Returns the sum of nums. (+) returns 0."
{:inline (fn [x y] `(. clojure.lang.Numbers (add ~x ~y)))
- :inline-arities #{2}}
+ :inline-arities #{2}
+ :added "1.0"}
([] 0)
([x] (cast Number x))
([x y] (. clojure.lang.Numbers (add x y)))
@@ -731,7 +804,8 @@
(defn *
"Returns the product of nums. (*) returns 1."
{:inline (fn [x y] `(. clojure.lang.Numbers (multiply ~x ~y)))
- :inline-arities #{2}}
+ :inline-arities #{2}
+ :added "1.0"}
([] 1)
([x] (cast Number x))
([x y] (. clojure.lang.Numbers (multiply x y)))
@@ -742,7 +816,8 @@
"If no denominators are supplied, returns 1/numerator,
else returns numerator divided by all of the denominators."
{:inline (fn [x y] `(. clojure.lang.Numbers (divide ~x ~y)))
- :inline-arities #{2}}
+ :inline-arities #{2}
+ :added "1.0"}
([x] (/ 1 x))
([x y] (. clojure.lang.Numbers (divide x y)))
([x y & more]
@@ -752,7 +827,8 @@
"If no ys are supplied, returns the negation of x, else subtracts
the ys from x and returns the result."
{:inline (fn [& args] `(. clojure.lang.Numbers (minus ~@args)))
- :inline-arities #{1 2}}
+ :inline-arities #{1 2}
+ :added "1.0"}
([x] (. clojure.lang.Numbers (minus x)))
([x y] (. clojure.lang.Numbers (minus x y)))
([x y & more]
@@ -762,7 +838,8 @@
"Returns non-nil if nums are in monotonically non-decreasing order,
otherwise false."
{:inline (fn [x y] `(. clojure.lang.Numbers (lte ~x ~y)))
- :inline-arities #{2}}
+ :inline-arities #{2}
+ :added "1.0"}
([x] true)
([x y] (. clojure.lang.Numbers (lte x y)))
([x y & more]
@@ -776,7 +853,8 @@
"Returns non-nil if nums are in monotonically decreasing order,
otherwise false."
{:inline (fn [x y] `(. clojure.lang.Numbers (gt ~x ~y)))
- :inline-arities #{2}}
+ :inline-arities #{2}
+ :added "1.0"}
([x] true)
([x y] (. clojure.lang.Numbers (gt x y)))
([x y & more]
@@ -790,7 +868,8 @@
"Returns non-nil if nums are in monotonically non-increasing order,
otherwise false."
{:inline (fn [x y] `(. clojure.lang.Numbers (gte ~x ~y)))
- :inline-arities #{2}}
+ :inline-arities #{2}
+ :added "1.0"}
([x] true)
([x y] (. clojure.lang.Numbers (gte x y)))
([x y & more]
@@ -803,7 +882,8 @@
(defn ==
"Returns non-nil if nums all have the same value, otherwise false"
{:inline (fn [x y] `(. clojure.lang.Numbers (equiv ~x ~y)))
- :inline-arities #{2}}
+ :inline-arities #{2}
+ :added "1.0"}
([x] true)
([x y] (. clojure.lang.Numbers (equiv x y)))
([x y & more]
@@ -815,6 +895,7 @@
(defn max
"Returns the greatest of the nums."
+ {:added "1.0"}
([x] x)
([x y] (if (> x y) x y))
([x y & more]
@@ -822,6 +903,7 @@
(defn min
"Returns the least of the nums."
+ {:added "1.0"}
([x] x)
([x y] (if (< x y) x y))
([x y & more]
@@ -829,81 +911,95 @@
(defn dec
"Returns a number one less than num."
- {:inline (fn [x] `(. clojure.lang.Numbers (dec ~x)))}
+ {:inline (fn [x] `(. clojure.lang.Numbers (dec ~x)))
+ :added "1.0"}
[x] (. clojure.lang.Numbers (dec x)))
(defn unchecked-inc
"Returns a number one greater than x, an int or long.
Note - uses a primitive operator subject to overflow."
- {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_inc ~x)))}
+ {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_inc ~x)))
+ :added "1.0"}
[x] (. clojure.lang.Numbers (unchecked_inc x)))
(defn unchecked-dec
"Returns a number one less than x, an int or long.
Note - uses a primitive operator subject to overflow."
- {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_dec ~x)))}
+ {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_dec ~x)))
+ :added "1.0"}
[x] (. clojure.lang.Numbers (unchecked_dec x)))
(defn unchecked-negate
"Returns the negation of x, an int or long.
Note - uses a primitive operator subject to overflow."
- {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_negate ~x)))}
+ {:inline (fn [x] `(. clojure.lang.Numbers (unchecked_negate ~x)))
+ :added "1.0"}
[x] (. clojure.lang.Numbers (unchecked_negate x)))
(defn unchecked-add
"Returns the sum of x and y, both int or long.
Note - uses a primitive operator subject to overflow."
- {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_add ~x ~y)))}
+ {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_add ~x ~y)))
+ :added "1.0"}
[x y] (. clojure.lang.Numbers (unchecked_add x y)))
(defn unchecked-subtract
"Returns the difference of x and y, both int or long.
Note - uses a primitive operator subject to overflow."
- {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_subtract ~x ~y)))}
+ {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_subtract ~x ~y)))
+ :added "1.0"}
[x y] (. clojure.lang.Numbers (unchecked_subtract x y)))
(defn unchecked-multiply
"Returns the product of x and y, both int or long.
Note - uses a primitive operator subject to overflow."
- {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_multiply ~x ~y)))}
+ {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_multiply ~x ~y)))
+ :added "1.0"}
[x y] (. clojure.lang.Numbers (unchecked_multiply x y)))
(defn unchecked-divide
"Returns the division of x by y, both int or long.
Note - uses a primitive operator subject to truncation."
- {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_divide ~x ~y)))}
+ {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_divide ~x ~y)))
+ :added "1.0"}
[x y] (. clojure.lang.Numbers (unchecked_divide x y)))
(defn unchecked-remainder
"Returns the remainder of division of x by y, both int or long.
Note - uses a primitive operator subject to truncation."
- {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_remainder ~x ~y)))}
+ {:inline (fn [x y] `(. clojure.lang.Numbers (unchecked_remainder ~x ~y)))
+ :added "1.0"}
[x y] (. clojure.lang.Numbers (unchecked_remainder x y)))
(defn pos?
"Returns true if num is greater than zero, else false"
{:tag Boolean
- :inline (fn [x] `(. clojure.lang.Numbers (isPos ~x)))}
+ :inline (fn [x] `(. clojure.lang.Numbers (isPos ~x)))
+ :added "1.0"}
[x] (. clojure.lang.Numbers (isPos x)))
(defn neg?
"Returns true if num is less than zero, else false"
{:tag Boolean
- :inline (fn [x] `(. clojure.lang.Numbers (isNeg ~x)))}
+ :inline (fn [x] `(. clojure.lang.Numbers (isNeg ~x)))
+ :added "1.0"}
[x] (. clojure.lang.Numbers (isNeg x)))
(defn quot
"quot[ient] of dividing numerator by denominator."
+ {:added "1.0"}
[num div]
(. clojure.lang.Numbers (quotient num div)))
(defn rem
"remainder of dividing numerator by denominator."
+ {:added "1.0"}
[num div]
(. clojure.lang.Numbers (remainder num div)))
(defn rationalize
"returns the rational value of num"
+ {:added "1.0"}
[num]
(. clojure.lang.Numbers (rationalize num)))
@@ -911,63 +1007,76 @@
(defn bit-not
"Bitwise complement"
- {:inline (fn [x] `(. clojure.lang.Numbers (not ~x)))}
+ {:inline (fn [x] `(. clojure.lang.Numbers (not ~x)))
+ :added "1.0"}
[x] (. clojure.lang.Numbers not x))
(defn bit-and
"Bitwise and"
- {:inline (fn [x y] `(. clojure.lang.Numbers (and ~x ~y)))}
+ {:inline (fn [x y] `(. clojure.lang.Numbers (and ~x ~y)))
+ :added "1.0"}
[x y] (. clojure.lang.Numbers and x y))
(defn bit-or
"Bitwise or"
- {:inline (fn [x y] `(. clojure.lang.Numbers (or ~x ~y)))}
+ {:inline (fn [x y] `(. clojure.lang.Numbers (or ~x ~y)))
+ :added "1.0"}
[x y] (. clojure.lang.Numbers or x y))
(defn bit-xor
"Bitwise exclusive or"
- {:inline (fn [x y] `(. clojure.lang.Numbers (xor ~x ~y)))}
+ {:inline (fn [x y] `(. clojure.lang.Numbers (xor ~x ~y)))
+ :added "1.0"}
[x y] (. clojure.lang.Numbers xor x y))
(defn bit-and-not
"Bitwise and with complement"
+ {:added "1.0"}
[x y] (. clojure.lang.Numbers andNot x y))
(defn bit-clear
"Clear bit at index n"
+ {:added "1.0"}
[x n] (. clojure.lang.Numbers clearBit x n))
(defn bit-set
"Set bit at index n"
+ {:added "1.0"}
[x n] (. clojure.lang.Numbers setBit x n))
(defn bit-flip
"Flip bit at index n"
+ {:added "1.0"}
[x n] (. clojure.lang.Numbers flipBit x n))
(defn bit-test
"Test bit at index n"
+ {:added "1.0"}
[x n] (. clojure.lang.Numbers testBit x n))
(defn bit-shift-left
"Bitwise shift left"
- {:inline (fn [x n] `(. clojure.lang.Numbers (shiftLeft ~x ~n)))}
+ {:inline (fn [x n] `(. clojure.lang.Numbers (shiftLeft ~x ~n)))
+ :added "1.0"}
[x n] (. clojure.lang.Numbers shiftLeft x n))
(defn bit-shift-right
"Bitwise shift right"
- {:inline (fn [x n] `(. clojure.lang.Numbers (shiftRight ~x ~n)))}
+ {:inline (fn [x n] `(. clojure.lang.Numbers (shiftRight ~x ~n)))
+ :added "1.0"}
[x n] (. clojure.lang.Numbers shiftRight x n))
(defn even?
"Returns true if n is even, throws an exception if n is not an integer"
+ {:added "1.0"}
[n] (zero? (bit-and n 1)))
(defn odd?
"Returns true if n is odd, throws an exception if n is not an integer"
+ {:added "1.0"}
[n] (not (even? n)))
@@ -976,6 +1085,7 @@
(defn complement
"Takes a fn f and returns a fn that takes the same arguments as f,
has the same effects, if any, and returns the opposite truth value."
+ {:added "1.0"}
[f]
(fn
([] (not (f)))
@@ -985,10 +1095,12 @@
(defn constantly
"Returns a function that takes any number of arguments and returns x."
+ {:added "1.0"}
[x] (fn [& args] x))
(defn identity
"Returns its argument."
+ {:added "1.0"}
[x] x)
;;Collection stuff
@@ -1001,6 +1113,7 @@
(defn peek
"For a list or queue, same as first, for a vector, same as, but much
more efficient than, last. If the collection is empty, returns nil."
+ {:added "1.0"}
[coll] (. clojure.lang.RT (peek coll)))
(defn pop
@@ -1008,6 +1121,7 @@
item, for a vector, returns a new vector without the last item. If
the collection is empty, throws an exception. Note - not the same
as next/butlast."
+ {:added "1.0"}
[coll] (. clojure.lang.RT (pop coll)))
;;map stuff
@@ -1018,12 +1132,14 @@
vectors and Java arrays, this tests if the numeric key is within the
range of indexes. 'contains?' operates constant or logarithmic time;
it will not perform a linear search for a value. See also 'some'."
+ {:added "1.0"}
[coll key] (. clojure.lang.RT (contains coll key)))
(defn get
"Returns the value mapped to key, not-found or nil if key not present."
{:inline (fn [m k & nf] `(. clojure.lang.RT (get ~m ~k ~@nf)))
- :inline-arities #{2 3}}
+ :inline-arities #{2 3}
+ :added "1.0"}
([map key]
(. clojure.lang.RT (get map key)))
([map key not-found]
@@ -1032,6 +1148,7 @@
(defn dissoc
"dissoc[iate]. Returns a new map of the same (hashed/sorted) type,
that does not contain a mapping for key(s)."
+ {:added "1.0"}
([map] map)
([map key]
(. clojure.lang.RT (dissoc map key)))
@@ -1044,6 +1161,7 @@
(defn disj
"disj[oin]. Returns a new set of the same (hashed/sorted) type, that
does not contain key(s)."
+ {:added "1.0"}
([set] set)
([^clojure.lang.IPersistentSet set key]
(. set (disjoin key)))
@@ -1055,10 +1173,12 @@
(defn find
"Returns the map entry for key, or nil if key not present."
+ {:added "1.0"}
[map key] (. clojure.lang.RT (find map key)))
(defn select-keys
"Returns a map containing only those entries in map whose key is in keys"
+ {:added "1.0"}
[map keyseq]
(loop [ret {} keys (seq keyseq)]
(if keys
@@ -1072,43 +1192,51 @@
(defn keys
"Returns a sequence of the map's keys."
+ {:added "1.0"}
[map] (. clojure.lang.RT (keys map)))
(defn vals
"Returns a sequence of the map's values."
+ {:added "1.0"}
[map] (. clojure.lang.RT (vals map)))
(defn key
"Returns the key of the map entry."
+ {:added "1.0"}
[^java.util.Map$Entry e]
(. e (getKey)))
(defn val
"Returns the value in the map entry."
+ {:added "1.0"}
[^java.util.Map$Entry e]
(. e (getValue)))
(defn rseq
"Returns, in constant time, a seq of the items in rev (which
can be a vector or sorted-map), in reverse order. If rev is empty returns nil"
+ {:added "1.0"}
[^clojure.lang.Reversible rev]
(. rev (rseq)))
(defn name
"Returns the name String of a symbol or keyword."
- {:tag String}
+ {:tag String
+ :added "1.0"}
[^clojure.lang.Named x]
(. x (getName)))
(defn namespace
"Returns the namespace String of a symbol or keyword, or nil if not present."
- {:tag String}
+ {:tag String
+ :added "1.0"}
[^clojure.lang.Named x]
(. x (getNamespace)))
(defmacro locking
"Executes exprs in an implicit do, while holding the monitor of x.
Will release the monitor of x in all circumstances."
+ {:added "1.0"}
[x & body]
`(let [lockee# ~x]
(try
@@ -1131,6 +1259,7 @@
(. (. System (getProperties)) (get \"os.name\"))
but is easier to write, read, and