Tupelo - Making Clojure even sweeter
Tupelo - Making Clojure even sweeter
Default output buffer size for lazy-gen
.
Default output buffer size for `lazy-gen`.
(->sorted-map map-in)
Inputs: [map-in :- tsk/Map] Returns: tsk/Map
Coerces a map into a sorted-map
Inputs: [map-in :- tsk/Map] Returns: tsk/Map Coerces a map into a sorted-map
(->vector & args)
(->vector & rest25584)
Inputs: [& args :- [s/Any]] Returns: [s/Any]
Wraps all args in a vector, as with clojure.core/vector
. Will (recursively) recognize
any embedded calls to (unwrap <vec-or-list>) and insert their elements as with the
unquote-spicing operator (~@). Examples:
(->vector 1 2 3 4 5 6 7 8 9) => [1 2 3 4 5 6 7 8 9]
(->vector 1 2 3 (unwrap [4 5 6]) 7 8 9) => [1 2 3 4 5 6 7 8 9]
Inputs: [& args :- [s/Any]] Returns: [s/Any] Wraps all args in a vector, as with `clojure.core/vector`. Will (recursively) recognize any embedded calls to (unwrap <vec-or-list>) and insert their elements as with the unquote-spicing operator (~@). Examples: (->vector 1 2 3 4 5 6 7 8 9) => [1 2 3 4 5 6 7 8 9] (->vector 1 2 3 (unwrap [4 5 6]) 7 8 9) => [1 2 3 4 5 6 7 8 9]
(append listy & elems)
(append G__25508 & rest25509)
Inputs: [listy :- tsk/List & elems :- [s/Any]] Returns: tsk/List
Given a sequential object (vector or list), add one or more elements to the end.
Inputs: [listy :- tsk/List & elems :- [s/Any]] Returns: tsk/List Given a sequential object (vector or list), add one or more elements to the end.
(chan->lazy-seq chan)
Accepts a core.async channel and returns the contents as a lazy list.
Accepts a core.async channel and returns the contents as a lazy list.
(char->int arg)
Inputs: [arg :- s/Any] Returns: s/Int
Convert a char to an unicode int
Inputs: [arg :- s/Any] Returns: s/Int Convert a char to an unicode int
(chars-thru start-char stop-char)
Given two characters (or numerical equivalents), returns a seq of characters (inclusive) from the first to the second. Characters must be in ascending order.
Given two characters (or numerical equivalents), returns a seq of characters (inclusive) from the first to the second. Characters must be in ascending order.
(check-spy-enabled tag & forms)
(check-spy-enabled &form &env tag & forms)
(clip-str nchars & args)
Converts all args to single string and clips any characters beyond nchars.
Converts all args to single string and clips any characters beyond nchars.
(cljs-env? env)
Take the &env from a macro, and tell whether we are expanding into cljs.
Take the &env from a macro, and tell whether we are expanding into cljs.
(cond-it-> & forms)
(cond-it-> &form &env & forms)
A threading macro like as-> that always uses the symbol 'it' as the placeholder for the next threaded value:
(let [params {:a 1 :b 1 :c nil :d nil}] (cond-it-> params (:a it) (update it :b inc) (= (:b it) 2) (assoc it :c "here") (:c it) (assoc it :d "again")))
;=> {:a 1, :b 2, :c "here", :d "again"}
A threading macro like as-> that always uses the symbol 'it' as the placeholder for the next threaded value: (let [params {:a 1 :b 1 :c nil :d nil}] (cond-it-> params (:a it) (update it :b inc) (= (:b it) 2) (assoc it :c "here") (:c it) (assoc it :d "again"))) ;=> {:a 1, :b 2, :c "here", :d "again"}
(contains-elem? coll elem)
Inputs: [coll :- s/Any elem :- s/Any] Returns: s/Bool
For any collection coll & element tgt, returns true if coll contains at least one instance of tgt; otherwise returns false. Note that, for maps, each element is a vector (i.e MapEntry) of the form [key value].
Inputs: [coll :- s/Any elem :- s/Any] Returns: s/Bool For any collection coll & element tgt, returns true if coll contains at least one instance of tgt; otherwise returns false. Note that, for maps, each element is a vector (i.e MapEntry) of the form [key value].
(contains-key? map-or-set elem)
Inputs: [map-or-set :- (s/pred (fn* [p1__14457#] (or (map? p1__14457#) (set? p1__14457#)))) elem :- s/Any] Returns: s/Bool
For any map or set, returns true if elem is a map key or set element, respectively
Inputs: [map-or-set :- (s/pred (fn* [p1__14457#] (or (map? p1__14457#) (set? p1__14457#)))) elem :- s/Any] Returns: s/Bool For any map or set, returns true if elem is a map key or set element, respectively
Inputs: [map-or-set :- (s/pred (fn* [p1__25287#] (or (map? p1__25287#) (set? p1__25287#)))) elem :- s/Any] Returns: s/Bool
For any map or set, returns true if elem is a map key or set element, respectively
Inputs: [map-or-set :- (s/pred (fn* [p1__25287#] (or (map? p1__25287#) (set? p1__25287#)))) elem :- s/Any] Returns: s/Bool For any map or set, returns true if elem is a map key or set element, respectively
(contains-val? map elem)
Inputs: [map :- tsk/Map elem :- s/Any] Returns: s/Bool
For any map, returns true if elem is present in the map for at least one key.
Inputs: [map :- tsk/Map elem :- s/Any] Returns: s/Bool For any map, returns true if elem is present in the map for at least one key.
(destruct bindings & forms)
(destruct &form &env bindings & forms)
Natural destructuring:
(let [data {:a 1
:b {:c 3
:d 4}}]
...
(destruct [data {:a ?
:b {:c ?}}]
...
then can use local values a=1, c=3. With vector data:
(let [data [1 2 3 4 5]]
...
(destruct [data [a b c]]
...
then can use local values a=1 b=2 c=3. Can use (restruct)
, (restruct data)
, or (restruct-all)
to re-structure & return original data shape using current values.
Natural destructuring: (let [data {:a 1 :b {:c 3 :d 4}}] ... (destruct [data {:a ? :b {:c ?}}] ... then can use local values a=1, c=3. With vector data: (let [data [1 2 3 4 5]] ... (destruct [data [a b c]] ... then can use local values a=1 b=2 c=3. Can use `(restruct)`, `(restruct data)`, or `(restruct-all)` to re-structure & return original data shape using current values.
(dissoc-in the-map keys-vec)
Inputs: [the-map :- tsk/KeyMap keys-vec :- [s/Keyword]] Returns: s/Any
A sane version of dissoc-in that will not delete intermediate keys. When invoked as (dissoc-in the-map [:k1 :k2 :k3... :kZ]), acts like (clojure.core/update-in the-map [:k1 :k2 :k3...] dissoc :kZ). That is, only the map entry containing the last key :kZ is removed, and all map entries higher than kZ in the hierarchy are unaffected.
Inputs: [the-map :- tsk/KeyMap keys-vec :- [s/Keyword]] Returns: s/Any A sane version of dissoc-in that will not delete intermediate keys. When invoked as (dissoc-in the-map [:k1 :k2 :k3... :kZ]), acts like (clojure.core/update-in the-map [:k1 :k2 :k3...] dissoc :kZ). That is, only the map entry containing the last key :kZ is removed, and all map entries higher than kZ in the hierarchy are unaffected.
(drop-at coll index)
Inputs: [coll :- tsk/List index :- s/Int] Returns: tsk/List
Removes an element from a collection at the specified index.
Inputs: [coll :- tsk/List index :- s/Int] Returns: tsk/List Removes an element from a collection at the specified index.
(drop-if pred coll)
Returns a vector of items in coll for which (pred item) is false (alias for clojure.core/remove)
Returns a vector of items in coll for which (pred item) is false (alias for clojure.core/remove)
(edn->json arg)
Inputs: [arg] Returns: s/Str
Shortcut to cheshire.core/generate-string
Inputs: [arg] Returns: s/Str Shortcut to cheshire.core/generate-string
Inputs: [arg] Returns: s/Str
Convert from edn -> json
Inputs: [arg] Returns: s/Str Convert from edn -> json
(ex-msg exception)
Returns the message from an exception => (.getMessage exception)
Returns the message from an exception => (.getMessage exception)
(ex-stacktrace exception)
Returns the stacktrace from an exception
Returns the stacktrace from an exception
(falsey? arg)
Returns true if arg is logical false (either nil or false); otherwise returns false. Equivalent to (not (truthy? arg)).
Returns true if arg is logical false (either nil or false); otherwise returns false. Equivalent to (not (truthy? arg)).
(fetch the-map the-key)
Inputs: [the-map :- tsk/Map the-key :- s/Any] Returns: s/Any
A fail-fast version of keyword/map lookup. When invoked as (fetch the-map :the-key), returns the value associated with :the-key as for (clojure.core/get the-map :the-key). Throws an Exception if :the-key is not present in the-map.
Inputs: [the-map :- tsk/Map the-key :- s/Any] Returns: s/Any A fail-fast version of keyword/map lookup. When invoked as (fetch the-map :the-key), returns the value associated with :the-key as for (clojure.core/get the-map :the-key). Throws an Exception if :the-key is not present in the-map.
(fetch-in the-map keys-vec)
Inputs: [the-map :- tsk/Map keys-vec :- tsk/Vec] Returns: s/Any
A fail-fast version of clojure.core/get-in. When invoked as (fetch-in the-map keys-vec), returns the value associated with keys-vec as for (clojure.core/get-in the-map keys-vec). Throws an Exception if the path keys-vec is not present in the-map.
Inputs: [the-map :- tsk/Map keys-vec :- tsk/Vec] Returns: s/Any A fail-fast version of clojure.core/get-in. When invoked as (fetch-in the-map keys-vec), returns the value associated with keys-vec as for (clojure.core/get-in the-map keys-vec). Throws an Exception if the path keys-vec is not present in the-map.
(fibo-nth N)
Returns the N'th Fibonacci number (zero-based). Note that N=91 corresponds to approx 2^62
Returns the N'th Fibonacci number (zero-based). Note that N=91 corresponds to approx 2^62
(fibo-thru limit)
Returns a vector of Fibonacci numbers up to limit (inclusive). Note that a 2^62 corresponds to 91'st Fibonacci number.
Returns a vector of Fibonacci numbers up to limit (inclusive). Note that a 2^62 corresponds to 91'st Fibonacci number.
(fibonacci-seq)
A lazy seq of Fibonacci numbers (memoized).
A lazy seq of Fibonacci numbers (memoized).
(forv & forms)
(forv &form &env & forms)
Like clojure.core/for but returns results in a vector. Not lazy.
Like clojure.core/for but returns results in a vector. Not lazy.
(glue & colls)
Glues together like collections:
(glue [1 2] [3 4] [5 6]) -> [1 2 3 4 5 6] (glue {:a 1} {:b 2} {:c 3}) -> {:a 1 :c 3 :b 2} (glue #{1 2} #{3 4} #{6 5}) -> #{1 2 6 5 3 4} (glue "I" " like " \a " nap!" ) -> "I like a nap!"
If you want to convert to a sorted set or map, just put an empty one first:
(glue (sorted-map) {:a 1} {:b 2} {:c 3}) -> {:a 1 :b 2 :c 3} (glue (sorted-set) #{1 2} #{3 4} #{6 5}) -> #{1 2 3 4 5 6}
If there are duplicate keys when using glue for maps or sets, then "the last one wins":
(glue {:band :VanHalen :singer :Dave} {:singer :Sammy})
Glues together like collections: (glue [1 2] [3 4] [5 6]) -> [1 2 3 4 5 6] (glue {:a 1} {:b 2} {:c 3}) -> {:a 1 :c 3 :b 2} (glue #{1 2} #{3 4} #{6 5}) -> #{1 2 6 5 3 4} (glue "I" " like " \a " nap!" ) -> "I like a nap!" If you want to convert to a sorted set or map, just put an empty one first: (glue (sorted-map) {:a 1} {:b 2} {:c 3}) -> {:a 1 :b 2 :c 3} (glue (sorted-set) #{1 2} #{3 4} #{6 5}) -> #{1 2 3 4 5 6} If there are duplicate keys when using glue for maps or sets, then "the last one wins": (glue {:band :VanHalen :singer :Dave} {:singer :Sammy})
(glue-rows coll-2d)
Convert a vector of vectors (2-dimensional) into a single vector (1-dimensional).
Equivalent to (apply glue ...)
Convert a vector of vectors (2-dimensional) into a single vector (1-dimensional). Equivalent to `(apply glue ...)`
(grab the-key the-map)
Inputs: [the-key :- s/Any the-map :- tsk/Map] Returns: s/Any
A fail-fast version of keyword/map lookup. When invoked as (grab :the-key the-map), returns the value associated with :the-key as for (clojure.core/get the-map :the-key). Throws an Exception if :the-key is not present in the-map.
Inputs: [the-key :- s/Any the-map :- tsk/Map] Returns: s/Any A fail-fast version of keyword/map lookup. When invoked as (grab :the-key the-map), returns the value associated with :the-key as for (clojure.core/get the-map :the-key). Throws an Exception if :the-key is not present in the-map.
(has-length? coll n)
Returns true if the collection has the indicated length. Does not hang for infinite sequences.
Returns true if the collection has the indicated length. Does not hang for infinite sequences.
(has-none? pred coll)
Inputs: [pred :- s/Any coll :- [s/Any]] Returns: s/Bool
For any predicate pred & collection coll, returns false if (pred x) is logical true for at least one x in coll; otherwise returns true. Equivalent to clojure.core/not-any?, but inverse of has-some?.
Inputs: [pred :- s/Any coll :- [s/Any]] Returns: s/Bool For any predicate pred & collection coll, returns false if (pred x) is logical true for at least one x in coll; otherwise returns true. Equivalent to clojure.core/not-any?, but inverse of has-some?.
(has-some? pred coll)
Inputs: [pred :- s/Any coll :- [s/Any]] Returns: s/Bool
For any predicate pred & collection coll, returns true if (pred x) is logical true for at least one x in coll; otherwise returns false. Like clojure.core/some, but returns only true or false.
Inputs: [pred :- s/Any coll :- [s/Any]] Returns: s/Bool For any predicate pred & collection coll, returns true if (pred x) is logical true for at least one x in coll; otherwise returns false. Like clojure.core/some, but returns only true or false.
(idx coll index-val)
Inputs: [coll :- tsk/List index-val :- s/Int]
Indexes into a vector, allowing negative index values
Inputs: [coll :- tsk/List index-val :- s/Int] Indexes into a vector, allowing negative index values
(if-cljs then else)
Return then if we are generating cljs code and else for Clojure code. https://groups.google.com/d/msg/clojurescript/iBY5HaQda4A/w1lAQi9_AwsJ
Return then if we are generating cljs code and else for Clojure code. https://groups.google.com/d/msg/clojurescript/iBY5HaQda4A/w1lAQi9_AwsJ
(if-java-1-7-plus if-form else-form)
If JVM is Java 1.7 or higher, evaluates if-form into code. Otherwise, evaluates else-form.
If JVM is Java 1.7 or higher, evaluates if-form into code. Otherwise, evaluates else-form.
(if-java-1-8-plus if-form else-form)
If JVM is Java 1.8 or higher, evaluates if-form into code. Otherwise, evaluates else-form.
If JVM is Java 1.8 or higher, evaluates if-form into code. Otherwise, evaluates else-form.
(increasing-or-equal? a b)
Inputs: [a :- tsk/List b :- tsk/List] Returns: s/Bool
Returns true iff the vectors are in (strictly) lexicographically increasing-or-equal order [1 2] [1] -> false [1 2] [1 1] -> false [1 2] [1 2] -> true [1 2] [1 2 nil] -> true [1 2] [1 2 3] -> true [1 2] [1 3] -> true [1 2] [2 1] -> true [1 2] [2] -> true
Inputs: [a :- tsk/List b :- tsk/List] Returns: s/Bool Returns true iff the vectors are in (strictly) lexicographically increasing-or-equal order [1 2] [1] -> false [1 2] [1 1] -> false [1 2] [1 2] -> true [1 2] [1 2 nil] -> true [1 2] [1 2 3] -> true [1 2] [1 3] -> true [1 2] [2 1] -> true [1 2] [2] -> true
(increasing? a b)
Inputs: [a :- tsk/List b :- tsk/List] Returns: s/Bool
Returns true iff the vectors are in (strictly) lexicographically increasing order [1 2] [1] -> false [1 2] [1 1] -> false [1 2] [1 2] -> false [1 2] [1 2 nil] -> true [1 2] [1 2 3] -> true [1 2] [1 3] -> true [1 2] [2 1] -> true [1 2] [2] -> true
Inputs: [a :- tsk/List b :- tsk/List] Returns: s/Bool Returns true iff the vectors are in (strictly) lexicographically increasing order [1 2] [1] -> false [1 2] [1 1] -> false [1 2] [1 2] -> false [1 2] [1 2 nil] -> true [1 2] [1 2 3] -> true [1 2] [1 3] -> true [1 2] [2 1] -> true [1 2] [2] -> true
(indent-lines-with indent-str txt)
Inputs: [indent-str :- s/Str txt :- s/Str] Returns: s/Str
Splits out each line of txt using clojure.string/split-lines, then indents each line by prepending it with the supplied string. Joins lines together into a single string result, with each line terminated by a single ewline.
Inputs: [indent-str :- s/Str txt :- s/Str] Returns: s/Str Splits out each line of txt using clojure.string/split-lines, then indents each line by prepending it with the supplied string. Joins lines together into a single string result, with each line terminated by a single ewline.
(index-using pred coll)
Finds the first index N where (< N (count coll)) such that (pred (drop N coll)) is truthy.
Returns nil
if no match found.
Finds the first index N where (< N (count coll)) such that (pred (drop N coll)) is truthy. Returns `nil` if no match found.
(indexed & colls)
Given one or more collections, returns a sequence of indexed tuples from the collections: (indexed xs ys zs) -> [ [0 x0 y0 z0] [1 x1 y1 z1] [2 x2 y2 z2] ... ]
Given one or more collections, returns a sequence of indexed tuples from the collections: (indexed xs ys zs) -> [ [0 x0 y0 z0] [1 x1 y1 z1] [2 x2 y2 z2] ... ]
(insert-at coll index elem)
Inputs: [coll :- tsk/List index :- s/Int elem :- s/Any] Returns: tsk/List
Inserts an element into a collection at the specified index.
Inputs: [coll :- tsk/List index :- s/Int elem :- s/Any] Returns: tsk/List Inserts an element into a collection at the specified index.
(int->char arg)
Inputs: [arg :- s/Int] Returns: s/Any
Convert a unicode int to a char
Inputs: [arg :- s/Int] Returns: s/Any Convert a unicode int to a char
(it-> expr & forms)
(it-> &form &env expr & forms)
A threading macro like as-> that always uses the symbol 'it' as the placeholder for the next threaded value: (it-> 1 (inc it) (+ it 3) (/ 10 it)) ;=> 2
A threading macro like as-> that always uses the symbol 'it' as the placeholder for the next threaded value: (it-> 1 (inc it) (+ it 3) (/ 10 it)) ;=> 2
(java-version-matches? version-str)
Inputs: [version-str :- s/Str] Returns: s/Bool
Returns true if Java version exactly matches supplied string.
Inputs: [version-str :- s/Str] Returns: s/Bool Returns true if Java version exactly matches supplied string.
(java-version-min? version-str)
Inputs: [version-str :- s/Str] Returns: s/Bool
Returns true if Java version is at least as great as supplied string. Sort is by lexicographic (alphabetic) order.
Inputs: [version-str :- s/Str] Returns: s/Bool Returns true if Java version is at least as great as supplied string. Sort is by lexicographic (alphabetic) order.
(json->edn json-str)
Inputs: [json-str :- s/Str]
Shortcut to cheshire.core/parse-string
Inputs: [json-str :- s/Str] Shortcut to cheshire.core/parse-string
Inputs: [json-str :- s/Str]
Convert from json -> edn
Inputs: [json-str :- s/Str] Convert from json -> edn
(keep-if pred coll)
Returns a vector of items in coll for which (pred item) is true (alias for clojure.core/filter)
Returns a vector of items in coll for which (pred item) is true (alias for clojure.core/filter)
(keyvals m)
Inputs: [m :- tsk/Map] Returns: [s/Any]
For any map m, returns the (alternating) keys & values of m as a vector, suitable for reconstructing m via (apply hash-map (keyvals m)). (keyvals {:a 1 :b 2} => [:a 1 :b 2]
Inputs: [m :- tsk/Map] Returns: [s/Any] For any map m, returns the (alternating) keys & values of m as a vector, suitable for reconstructing m via (apply hash-map (keyvals m)). (keyvals {:a 1 :b 2} => [:a 1 :b 2]
(keyvals-seq ctx)
(keyvals-seq the-map the-keys)
(keyvals-seq G__25689)
(keyvals-seq G__25693 G__25694)
Inputs: ([ctx :- tsk/KeyMap] [the-map :- tsk/KeyMap the-keys :- [s/Any]]) Returns: [s/Any]
For any map m, returns the (alternating) keys & values of m as a vector, suitable for reconstructing m via (apply hash-map (keyvals m)). (keyvals {:a 1 :b 2} => [:a 1 :b 2]
Usage: (keyvals-seq ctx) ctx-default: {:missing-ok false} (keyvals-seq the-map the-keys)
Inputs: ([ctx :- tsk/KeyMap] [the-map :- tsk/KeyMap the-keys :- [s/Any]]) Returns: [s/Any] For any map m, returns the (alternating) keys & values of m as a vector, suitable for reconstructing m via (apply hash-map (keyvals m)). (keyvals {:a 1 :b 2} => [:a 1 :b 2] Usage: (keyvals-seq ctx) ctx-default: {:missing-ok false} (keyvals-seq the-map the-keys)
(keyvals-seq-impl ctx)
Inputs: [ctx :- tsk/KeyMap] Returns: [s/Any]
Inputs: [ctx :- tsk/KeyMap] Returns: [s/Any]
(kw->str arg)
Inputs: [arg :- s/Keyword] Returns: s/Str
Converts a keyword to a string
Inputs: [arg :- s/Keyword] Returns: s/Str Converts a keyword to a string
(kw->sym arg)
Inputs: [arg :- s/Keyword] Returns: s/Symbol
Converts a keyword to a symbol
Inputs: [arg :- s/Keyword] Returns: s/Symbol Converts a keyword to a symbol
(lazy-cons curr-val recursive-call-form)
The simple way to create a lazy sequence: (defn lazy-next-int [n] (t/lazy-cons n (lazy-next-int (inc n)))) (def all-ints (lazy-next-int 0))
The simple way to create a lazy sequence: (defn lazy-next-int [n] (t/lazy-cons n (lazy-next-int (inc n)))) (def all-ints (lazy-next-int 0))
(lazy-gen & forms)
Creates a 'generator function' that returns a lazy seq of results
via yield
(a la Python).
Creates a 'generator function' that returns a lazy seq of results via `yield` (a la Python).
(let-some bindings & forms)
(let-some &form &env bindings & forms)
Threads forms as with when-some
, but allow more than 1 pair of binding forms.
Threads forms as with `when-some`, but allow more than 1 pair of binding forms.
(let-spy & exprs)
(let-spy &form &env & exprs)
An expression (println ...) for use in threading forms (& elsewhere). Evaluates the supplied expressions, printing both the expression and its value to stdout. Returns the value of the last expression.
An expression (println ...) for use in threading forms (& elsewhere). Evaluates the supplied expressions, printing both the expression and its value to stdout. Returns the value of the last expression.
(let-spy-pretty & exprs)
(let-spy-pretty &form &env & exprs)
An expression (println ...) for use in threading forms (& elsewhere). Evaluates the supplied expressions, printing both the expression and its value to stdout. Returns the value of the last expression.
An expression (println ...) for use in threading forms (& elsewhere). Evaluates the supplied expressions, printing both the expression and its value to stdout. Returns the value of the last expression.
(lexical-compare a b)
Inputs: [a :- tsk/List b :- tsk/List] Returns: s/Int
Performs a lexical comparison of 2 sequences, sorting as follows: [1] [1 :a] [1 :b] [1 :b 3] [2] [3] [3 :y]
Inputs: [a :- tsk/List b :- tsk/List] Returns: s/Int Performs a lexical comparison of 2 sequences, sorting as follows: [1] [1 :a] [1 :b] [1 :b 3] [2] [3] [3 :y]
(macro? s)
Returns true if a quoted symbol resolves to a macro. Usage:
(println (macro? 'and)) ;=> true
Returns true if a quoted symbol resolves to a macro. Usage: (println (macro? 'and)) ;=> true
(map-keys map-in tx-fn & tx-args)
(map-keys G__25737 G__25738 & rest25739)
Inputs: [map-in :- tsk/Map tx-fn :- tsk/Fn & tx-args] Returns: tsk/Map
Transforms each key in a map using the supplied tx-fn
:
(t/map-keys {1 :a 2 :b 3 :c} inc) => { 2 :a 3 :b 4 :c} (t/map-keys {1 :a 2 :b 3 :c} {1 101 2 202 3 303}) => {101 :a 202 :b 303 :c}
Inputs: [map-in :- tsk/Map tx-fn :- tsk/Fn & tx-args] Returns: tsk/Map Transforms each key in a map using the supplied `tx-fn`: (t/map-keys {1 :a 2 :b 3 :c} inc) => { 2 :a 3 :b 4 :c} (t/map-keys {1 :a 2 :b 3 :c} {1 101 2 202 3 303}) => {101 :a 202 :b 303 :c}
(map-let bindings & forms)
(map-let &form &env bindings & forms)
Usage: (map-let bindings & forms)
Given bindings and forms like (map-let [x xs, y ys, ...] (+ x y))
, will iterate over the
collections [xs ys ...] assigning successive values of each collection to [x y ...], respectively.
The local symbols [x y ...] can then be used in forms
to generate the output mapping.
Will throw if collections are not all of the same length. Not lazy.
Usage: (map-let bindings & forms) Given bindings and forms like `(map-let [x xs, y ys, ...] (+ x y))`, will iterate over the collections [xs ys ...] assigning successive values of each collection to [x y ...], respectively. The local symbols [x y ...] can then be used in `forms` to generate the output mapping. Will throw if collections are not all of the same length. Not lazy.
(map-let* context bindings & forms)
(map-let* &form &env context bindings & forms)
Usage: (map-let* ctx bindings & forms)
where ctx is a map with default values: {:strict true :lazy false}
Usage: (map-let* ctx bindings & forms) where ctx is a map with default values: {:strict true :lazy false}
(map-vals map-in tx-fn & tx-args)
(map-vals G__25757 G__25758 & rest25759)
Inputs: [map-in :- tsk/Map tx-fn :- tsk/Fn & tx-args] Returns: tsk/Map
Transforms each value in a map using the supplied tx-fn
:
(t/map-vals {:a 1 :b 2 :c 3} inc) => {:a 2, :b 3, :c 4}
(t/map-vals {:a 1 :b 2 :c 3} {1 101 2 202 3 303}) => {:a 101, :b 202, :c 303}
Inputs: [map-in :- tsk/Map tx-fn :- tsk/Fn & tx-args] Returns: tsk/Map Transforms each value in a map using the supplied `tx-fn`: (t/map-vals {:a 1 :b 2 :c 3} inc) => {:a 2, :b 3, :c 4} (t/map-vals {:a 1 :b 2 :c 3} {1 101 2 202 3 303}) => {:a 101, :b 202, :c 303}
(matches? pattern & values)
A shortcut to clojure.core.match/match to aid in testing. Returns true if the data value matches the pattern value. Underscores serve as wildcard values. Usage:
(matches? pattern & values)
sample:
(matches? [1 _ 3] [1 2 3] ) ;=> true (matches? {:a _ :b _ :c 3} {:a 1 :b [1 2 3] :c 3} {:a 2 :b 99 :c 3} {:a 3 :b nil :c 3} ) ;=> true
Note that a wildcald can match either a primitive or a composite value.
A shortcut to clojure.core.match/match to aid in testing. Returns true if the data value matches the pattern value. Underscores serve as wildcard values. Usage: (matches? pattern & values) sample: (matches? [1 _ 3] [1 2 3] ) ;=> true (matches? {:a _ :b _ :c 3} {:a 1 :b [1 2 3] :c 3} {:a 2 :b 99 :c 3} {:a 3 :b nil :c 3} ) ;=> true Note that a wildcald can match either a primitive or a composite value.
(not-empty? coll)
Inputs: [coll] Returns: s/Bool
For any collection coll, returns true if coll contains any items; otherwise returns false. Equivalent to (not (empty? coll)).
Inputs: [coll] Returns: s/Bool For any collection coll, returns true if coll contains any items; otherwise returns false. Equivalent to (not (empty? coll)).
(not-nil? arg)
Inputs: [arg :- s/Any] Returns: s/Bool
Returns true if arg is not nil; false otherwise. Equivalent to (not (nil? arg)), or the poorly-named clojure.core/some?
Inputs: [arg :- s/Any] Returns: s/Bool Returns true if arg is not nil; false otherwise. Equivalent to (not (nil? arg)), or the poorly-named clojure.core/some?
(onlies coll)
Given an outer collection of length-1 collections, returns a sequence of the unwrapped values. (onlies [ [1] [2] [3] ]) => [1 2 3] (onlies #{ [1] [2] [3] }) => #{1 2 3}
Given an outer collection of length-1 collections, returns a sequence of the unwrapped values. (onlies [ [1] [2] [3] ]) => [1 2 3] (onlies #{ [1] [2] [3] }) => #{1 2 3}
(only coll)
Ensures that a sequence is of length=1, and returns the only value present. Throws an exception if the length of the sequence is not one. Note that, for a length-1 sequence S, (first S), (last S) and (only S) are equivalent.
Ensures that a sequence is of length=1, and returns the only value present. Throws an exception if the length of the sequence is not one. Note that, for a length-1 sequence S, (first S), (last S) and (only S) are equivalent.
(only2 coll)
Given a collection like [[5]]
, returns 5
. Equivalent to (only (only coll))
.
Given a collection like `[[5]]`, returns `5`. Equivalent to `(only (only coll))`.
(pair? coll)
Returns true if the collection contains exactly 2 items.
Returns true if the collection contains exactly 2 items.
(partition-using pred values)
Inputs: [pred :- s/Any values :- tsk/List]
Partitions a collection into vector of segments based on a predicate with a collection argument.
The first segment is initialized by removing the first element from values
, with subsequent
elements similarly transferred as long as (pred remaining-values)
is falsey. When
(pred remaining-values)
becomes truthy, the algorithm begins building the next segment.
Thus, the first partition finds the smallest N (< 0 N) such that (pred (drop N values))
is true, and constructs the segment as (take N values). If pred is never satisified,
[values] is returned.
Inputs: [pred :- s/Any values :- tsk/List] Partitions a collection into vector of segments based on a predicate with a collection argument. The first segment is initialized by removing the first element from `values`, with subsequent elements similarly transferred as long as `(pred remaining-values)` is falsey. When `(pred remaining-values)` becomes truthy, the algorithm begins building the next segment. Thus, the first partition finds the smallest N (< 0 N) such that (pred (drop N values)) is true, and constructs the segment as (take N values). If pred is never satisified, [values] is returned.
(prepend & args)
(prepend & rest25516)
Inputs: [& args] Returns: tsk/List
Given a sequential object (vector or list), add one or more elements to the beginning
Inputs: [& args] Returns: tsk/List Given a sequential object (vector or list), add one or more elements to the beginning
(prettify coll)
Recursively walks a data structure and returns a prettified version. Converts all lists to vectors. Converts all maps & sets to sorted collections.
Recursively walks a data structure and returns a prettified version. Converts all lists to vectors. Converts all maps & sets to sorted collections.
(pretty arg)
(pretty arg writer)
Shortcut to clojure.pprint/pprint. Returns it (1st) argument.
Shortcut to clojure.pprint/pprint. Returns it (1st) argument.
(pretty-str arg)
Returns a string that is the result of clojure.pprint/pprint
Returns a string that is the result of clojure.pprint/pprint
(quad? coll)
Returns true if the collection contains exactly 4 items.
Returns true if the collection contains exactly 4 items.
(rand-elem coll)
Returns a random element from a collection
Returns a random element from a collection
(range-vec & args)
An eager version clojure.core/range that always returns its result in a vector.
An eager version clojure.core/range that always returns its result in a vector.
(rel= val1 val2 & {:as opts})
Returns true if 2 double-precision numbers are relatively equal, else false. Relative equality is specified as either (1) the N most significant digits are equal, or (2) the absolute difference is less than a tolerance value. Input values are coerced to double before comparison. Example:
(rel= 123450000 123456789 :digits 4 ) ; true (rel= 1 1.001 :tol 0.01) ; true
Returns true if 2 double-precision numbers are relatively equal, else false. Relative equality is specified as either (1) the N most significant digits are equal, or (2) the absolute difference is less than a tolerance value. Input values are coerced to double before comparison. Example: (rel= 123450000 123456789 :digits 4 ) ; true (rel= 1 1.001 :tol 0.01) ; true
(replace-at coll index elem)
Inputs: [coll :- tsk/List index :- s/Int elem :- s/Any] Returns: tsk/List
Replaces an element in a collection at the specified index.
Inputs: [coll :- tsk/List index :- s/Int elem :- s/Any] Returns: tsk/List Replaces an element in a collection at the specified index.
(restruct & args)
within a (destruct [<data> <shape>] ...) form,
(restruct)or
(restruct <data>)` causes re-structuring
& return of original data shape using current values.
within a `(destruct [<data> <shape>] ...) form, `(restruct)` or `(restruct <data>)` causes re-structuring & return of original data shape using current values.
(restruct-all & args)
within a `(destruct [data-1 <shape-1> data-2 <shape-2] ...) form, causes re-structuring & return of original data shapes using current values as with (vals->map data-1 data-2 ...)
within a `(destruct [data-1 <shape-1> data-2 <shape-2] ...) form, causes re-structuring & return of original data shapes using current values as with (vals->map data-1 data-2 ...)
(seq->str seq-in)
Convert a seq into a string (using pr) with a space preceding each value
Convert a seq into a string (using pr) with a space preceding each value
(sequential->idx-map data)
Inputs: [data :- [s/Any]] Returns: #:s{Any s/Any}
Inputs: [data :- [s/Any]] Returns: #:s{Any s/Any}
(single? coll)
Returns true if the collection contains a single item.`
Returns true if the collection contains a single item.`
(some-it-> expr & forms)
(some-it-> &form &env expr & forms)
Threads forms as with it->
, terminates & returns nil
if any expression is nil.
Threads forms as with `it->`, terminates & returns `nil` if any expression is nil.
(split-match coll tgt)
Splits a collection src by matching with a sub-sequence tgt of length L. Finds the first index N such that (= tgt (->> coll (drop N) (take L))) is true. Returns a length-2 vector of [ (take N coll) (drop N coll) ]. If no match is found, [ coll [] ] is returned.
Splits a collection src by matching with a sub-sequence tgt of length L. Finds the first index N such that (= tgt (->> coll (drop N) (take L))) is true. Returns a length-2 vector of [ (take N coll) (drop N coll) ]. If no match is found, [ coll [] ] is returned.
(split-using pred coll)
Splits a collection based on a predicate with a collection argument. Finds the first index N such that (pred (drop N coll)) is true. Returns a length-2 vector of [ (take N coll) (drop N coll) ]. If pred is never satisified, [ coll [] ] is returned.
Splits a collection based on a predicate with a collection argument. Finds the first index N such that (pred (drop N coll)) is true. Returns a length-2 vector of [ (take N coll) (drop N coll) ]. If pred is never satisified, [ coll [] ] is returned.
(spy value)
(spy arg1 arg2)
A form of (println ...) to ease debugging display of either intermediate values in threading forms or function return values. There are three variants. Usage:
(spy :msg <msg-string>) This variant is intended for use in either thread-first (->) or thread-last (->>) forms. The keyword :msg is used to identify the message string and works equally well for both the -> and ->> operators. Spy prints both <msg-string> and the threading value to stdout, then returns the value for further propogation in the threading form. For example, both of the following: (-> 2 (+ 3) (spy :msg "sum" ) (* 4)) (->> 2 (+ 3) (spy :msg "sum" ) (* 4)) will print 'sum => 5' to stdout.
(spy <msg-string> <value>) This variant is intended for simpler use cases such as function return values. Function return value expressions often invoke other functions and cannot be easily displayed since (println ...) swallows the return value and returns nil itself. Spy will output both <msg-string> and the value, then return the value for use by further processing. For example, the following: (println (* 2 (spy "sum" (+ 3 4)))) will print: sum => 7 14 to stdout.
(spy <value>) This variant is intended for use in very simple situations and is the same as the 2-argument arity where <msg-string> defaults to 'spy'. For example (spy (+ 2 3)) prints 'spy => 5' to stdout.
A form of (println ...) to ease debugging display of either intermediate values in threading forms or function return values. There are three variants. Usage: (spy :msg <msg-string>) This variant is intended for use in either thread-first (->) or thread-last (->>) forms. The keyword :msg is used to identify the message string and works equally well for both the -> and ->> operators. Spy prints both <msg-string> and the threading value to stdout, then returns the value for further propogation in the threading form. For example, both of the following: (-> 2 (+ 3) (spy :msg "sum" ) (* 4)) (->> 2 (+ 3) (spy :msg "sum" ) (* 4)) will print 'sum => 5' to stdout. (spy <msg-string> <value>) This variant is intended for simpler use cases such as function return values. Function return value expressions often invoke other functions and cannot be easily displayed since (println ...) swallows the return value and returns nil itself. Spy will output both <msg-string> and the value, then return the value for use by further processing. For example, the following: (println (* 2 (spy "sum" (+ 3 4)))) will print: sum => 7 14 to stdout. (spy <value>) This variant is intended for use in very simple situations and is the same as the 2-argument arity where <msg-string> defaults to 'spy'. For example (spy (+ 2 3)) prints 'spy => 5' to stdout.
(spy-pretty & exprs)
(spy-pretty &form &env & exprs)
Like spyx-pretty
but without printing the original form
Like `spyx-pretty` but without printing the original form
(spyx & exprs)
(spyx &form &env & exprs)
An expression (println ...) for use in threading forms (& elsewhere). Evaluates the supplied expressions, printing both the expression and its value to stdout. Returns the value of the last expression.
An expression (println ...) for use in threading forms (& elsewhere). Evaluates the supplied expressions, printing both the expression and its value to stdout. Returns the value of the last expression.
(spyx-pretty & exprs)
(spyx-pretty &form &env & exprs)
Like spyx
but with pretty printing (clojure.pprint/pprint)
Like `spyx` but with pretty printing (clojure.pprint/pprint)
(spyxx expr)
An expression (println ...) for use in threading forms (& elsewhere). Evaluates the supplied expression, printing both the expression, its type, and its value to stdout, then returns the value.
An expression (println ...) for use in threading forms (& elsewhere). Evaluates the supplied expression, printing both the expression, its type, and its value to stdout, then returns the value.
(starts-with? coll tgt-in)
Inputs: [coll tgt-in] Returns: s/Bool
Returns true when the initial elements of coll match those of tgt
Inputs: [coll tgt-in] Returns: s/Bool Returns true when the initial elements of coll match those of tgt
(str->chars arg)
Inputs: [arg :- s/Str] Returns: [s/Any]
Converts a string to a vector of chars
Inputs: [arg :- s/Str] Returns: [s/Any] Converts a string to a vector of chars
(str->kw arg)
Inputs: [arg :- s/Str] Returns: s/Keyword
Converts a string to a keyword
Inputs: [arg :- s/Str] Returns: s/Keyword Converts a string to a keyword
(str->sym arg)
Inputs: [arg :- s/Str] Returns: s/Symbol
Converts a string to a symbol
Inputs: [arg :- s/Str] Returns: s/Symbol Converts a string to a symbol
(strcat & args)
Recursively concatenate all arguments into a single string result.
Recursively concatenate all arguments into a single string result.
(string-increasing-or-equal? a b)
Inputs: [a :- s/Str b :- s/Str] Returns: s/Bool
Returns true if a pair of strings are in increasing lexicographic order, or equal.
Inputs: [a :- s/Str b :- s/Str] Returns: s/Bool Returns true if a pair of strings are in increasing lexicographic order, or equal.
(string-increasing? a b)
Inputs: [a :- s/Str b :- s/Str] Returns: s/Bool
Returns true if a pair of strings are in increasing lexicographic order.
Inputs: [a :- s/Str b :- s/Str] Returns: s/Bool Returns true if a pair of strings are in increasing lexicographic order.
(submap-by-keys map-arg keep-keys & opts)
(submap-by-keys G__25635 G__25636 & rest25637)
Inputs: [map-arg :- tsk/Map keep-keys :- (s/either tsk/Set tsk/List) & opts] Returns: tsk/Map
Returns a new map containing entries with the specified keys. Throws for missing keys,
unless :missing-ok
is specified. Usage:
(submap-by-keys {:a 1 :b 2} #{:a } ) => {:a 1}
(submap-by-keys {:a 1 :b 2} #{:a :z} :missing-ok ) => {:a 1}
Inputs: [map-arg :- tsk/Map keep-keys :- (s/either tsk/Set tsk/List) & opts] Returns: tsk/Map Returns a new map containing entries with the specified keys. Throws for missing keys, unless `:missing-ok` is specified. Usage: (submap-by-keys {:a 1 :b 2} #{:a } ) => {:a 1} (submap-by-keys {:a 1 :b 2} #{:a :z} :missing-ok ) => {:a 1}
(submap-by-vals map-arg keep-vals & opts)
(submap-by-vals G__25655 G__25656 & rest25657)
Inputs: [map-arg :- tsk/Map keep-vals :- (s/either tsk/Set tsk/List) & opts] Returns: tsk/Map
Returns a new map containing entries with the specified vals. Throws for missing vals,
unless :missing-ok
is specified. Usage:
(submap-by-vals {:a 1 :b 2 :A 1} #{1 } ) => {:a 1 :A 1}
(submap-by-vals {:a 1 :b 2 :A 1} #{1 9} :missing-ok ) => {:a 1 :A 1}
Inputs: [map-arg :- tsk/Map keep-vals :- (s/either tsk/Set tsk/List) & opts] Returns: tsk/Map Returns a new map containing entries with the specified vals. Throws for missing vals, unless `:missing-ok` is specified. Usage: (submap-by-vals {:a 1 :b 2 :A 1} #{1 } ) => {:a 1 :A 1} (submap-by-vals {:a 1 :b 2 :A 1} #{1 9} :missing-ok ) => {:a 1 :A 1}
(submap? inner-map outer-map)
Inputs: [inner-map :- #:s{Any s/Any} outer-map :- #:s{Any s/Any}] Returns: s/Bool
Returns true if the map entries (key-value pairs) of one map are a subset of the entries of another map. Similar to clojure.set/subset?
Inputs: [inner-map :- #:s{Any s/Any} outer-map :- #:s{Any s/Any}] Returns: s/Bool Returns true if the map entries (key-value pairs) of one map are a subset of the entries of another map. Similar to clojure.set/subset?
(submatch? smaller larger)
Returns true if the first arg is (recursively) a subset/submap/subvec of the 2nd arg
Returns true if the first arg is (recursively) a subset/submap/subvec of the 2nd arg
(swap-out! tgt-atom swap-fn & args)
Just like clojure.core/swap!, but returns the old value
Just like clojure.core/swap!, but returns the old value
(sym->kw arg)
Inputs: [arg :- s/Symbol] Returns: s/Keyword
Converts a symbol to a keyword
Inputs: [arg :- s/Symbol] Returns: s/Keyword Converts a symbol to a keyword
(sym->str arg)
Inputs: [arg :- s/Symbol] Returns: s/Str
Converts a symbol to a string
Inputs: [arg :- s/Symbol] Returns: s/Str Converts a symbol to a string
(thru end)
(thru start end)
(thru start end step)
Returns a sequence of integers. Like clojure.core/rng, but is inclusive of the right boundary value. Not lazy.
Returns a sequence of integers. Like clojure.core/rng, but is inclusive of the right boundary value. Not lazy.
(triple? coll)
Returns true if the collection contains exactly 3 items.
Returns true if the collection contains exactly 3 items.
(truthy? arg)
Returns true if arg is logical true (neither nil nor false); otherwise returns false.
Returns true if arg is logical true (neither nil nor false); otherwise returns false.
(try-catchall & body)
(try-catchall &form &env & body)
A cross-platform variant of try-catch that catches all exceptions. Does not (yet) support finally, and does not need or want an exception class.
A cross-platform variant of try-catch that catches all exceptions. Does not (yet) support finally, and does not need or want an exception class.
(unlazy coll)
Converts a lazy collection to a concrete (eager) collection of the same type.
Converts a lazy collection to a concrete (eager) collection of the same type.
(unnest & values)
(unnest & rest25590)
Inputs: [& values] Returns: [s/Any]
Given any set of arguments including vectors, maps, sets, & scalars, performs a depth-first recursive walk returning scalar args (int, string, keyword, etc) in a single 1-D vector.
Inputs: [& values] Returns: [s/Any] Given any set of arguments including vectors, maps, sets, & scalars, performs a depth-first recursive walk returning scalar args (int, string, keyword, etc) in a single 1-D vector.
(unwrap data)
Inputs: [data :- [s/Any]] Returns: Unwrapped
Works with the ->vector
function to unwrap vectors/lists to insert
their elements as with the unquote-spicing operator (~@). Examples:
(->vector 1 2 3 4 5 6 7 8 9) => [1 2 3 4 5 6 7 8 9]
(->vector 1 2 3 (unwrap [4 5 6]) 7 8 9) => [1 2 3 4 5 6 7 8 9]
Inputs: [data :- [s/Any]] Returns: Unwrapped Works with the `->vector` function to unwrap vectors/lists to insert their elements as with the unquote-spicing operator (~@). Examples: (->vector 1 2 3 4 5 6 7 8 9) => [1 2 3 4 5 6 7 8 9] (->vector 1 2 3 (unwrap [4 5 6]) 7 8 9) => [1 2 3 4 5 6 7 8 9]
(val= & vals)
(val= & rest25803)
Inputs: [& vals] Returns: s/Bool
Compares values for equality using clojure.core/=, treating records as plain map values:
(defrecord SampleRec [a b])
(assert (val= (->SampleRec 1 2) {:a 1 :b 2})) ; fails for clojure.core/=
Inputs: [& vals] Returns: s/Bool Compares values for equality using clojure.core/=, treating records as plain map values: (defrecord SampleRec [a b]) (assert (val= (->SampleRec 1 2) {:a 1 :b 2})) ; fails for clojure.core/=
(validate tst-fn tst-val)
(validate tst-fn tst-val) Used to validate intermediate results. Returns tst-val if the result of (tst-fn tst-val) is truthy. Otherwise, throws ex-info with ex-data {:sample-val sample-val :tst-result tst-result}.
(validate tst-fn tst-val) Used to validate intermediate results. Returns tst-val if the result of (tst-fn tst-val) is truthy. Otherwise, throws ex-info with ex-data {:sample-val sample-val :tst-result tst-result}.
(validate-map-keys tst-map valid-keys)
Inputs: [tst-map :- tsk/Map valid-keys :- MapKeySpec] Returns: s/Any
Inputs: [tst-map :- tsk/Map valid-keys :- MapKeySpec] Returns: s/Any
(validate-or-default is-valid? sample-val default-val)
Returns sample-val
if (is-valid? sample-val)
is truthy; else returns default-val
Returns `sample-val` if `(is-valid? sample-val)` is truthy; else returns `default-val`
(vals->map & symbols)
(vals->map &form &env & symbols)
Called with a list of symbols like (vals->map a b c)
returns a map
like {:a a :b b :c c}.
(let [a 1
b 2
c 3]
(vals->map a b c)) ;=> {:a 1 :b 2 :c 3} }
See with-map-vals
for simple destructuring of such maps.
Called with a list of symbols like `(vals->map a b c)` returns a map like {:a a :b b :c c}. (let [a 1 b 2 c 3] (vals->map a b c)) ;=> {:a 1 :b 2 :c 3} } See `with-map-vals` for simple destructuring of such maps.
(verify form)
(verify <some-expr>) Used to verify intermediate results. Returns value of <some-expr> if the result is truthy. Otherwise, throws an Exception.
(verify <some-expr>) Used to verify intermediate results. Returns value of <some-expr> if the result is truthy. Otherwise, throws an Exception.
(when-clojure-1-8-plus & forms)
Wraps code that should only be included for Clojure 1.8 or higher. Otherwise, code is supressed.
Wraps code that should only be included for Clojure 1.8 or higher. Otherwise, code is supressed.
(when-clojure-1-9-plus & forms)
Wraps code that should only be included for Clojure 1.9 or higher. Otherwise, code is supressed.
Wraps code that should only be included for Clojure 1.9 or higher. Otherwise, code is supressed.
(when-not-clojure-1-9-plus & forms)
Wraps code that should only be included for Clojure versions prior to 1.9. Otherwise, code is supressed.
Wraps code that should only be included for Clojure versions prior to 1.9. Otherwise, code is supressed.
(wild-item? item)
Inputs: [item :- s/Any] Returns: s/Bool
Returns true if any element in a nested collection is the wildcard :*
Inputs: [item :- s/Any] Returns: s/Bool Returns true if any element in a nested collection is the wildcard :*
Returns true if a pattern is matched by one or more values. The special keyword :* (colon-star) in the pattern serves as a wildcard value. Note that a wildcald can match either a primitive or a composite value: Classic usage:
(wild-match? pattern & values)
examples:
(wild-match? {:a :* :b 2} {:a 1 :b 2}) ;=> true
(wild-match? [1 :* 3] [1 2 3] [1 9 3] )) ;=> true
(wild-match? {:a :* :b 2} {:a [1 2 3] :b 2}) ;=> true
wild-match? also accepts a context map; usage:
(wild-match? ctx)
example (default values shown):
(wild-match? { :submap-ok false :subset-ok false :subvec-ok false :wildcard-ok true :pattern <required param> :values [ <patttern-spec>+ ] ; vector of 1 or more required } )
Returns true if a pattern is matched by one or more values. The special keyword :* (colon-star) in the pattern serves as a wildcard value. Note that a wildcald can match either a primitive or a composite value: Classic usage: (wild-match? pattern & values) examples: (wild-match? {:a :* :b 2} {:a 1 :b 2}) ;=> true (wild-match? [1 :* 3] [1 2 3] [1 9 3] )) ;=> true (wild-match? {:a :* :b 2} {:a [1 2 3] :b 2}) ;=> true wild-match? also accepts a context map; usage: (wild-match? ctx) example (default values shown): (wild-match? { :submap-ok false :subset-ok false :subvec-ok false :wildcard-ok true :pattern <required param> :values [ <patttern-spec>+ ] ; vector of 1 or more required } )
(wild-submatch? pattern & values)
Simple wrapper for wild-match? where all types of sub-matching are enabled.
Simple wrapper for wild-match? where all types of sub-matching are enabled.
(with-err-str & body)
(with-err-str &form &env & body)
Evaluates exprs in a context in which err is bound to a fresh StringWriter. Returns the string created by any nested printing calls.
Evaluates exprs in a context in which *err* is bound to a fresh StringWriter. Returns the string created by any nested printing calls.
(with-exception-default default-val & forms)
(with-exception-default &form &env default-val & forms)
Evaluates body & returns its result. In the event of an exception, default-val is returned instead of the exception.
Evaluates body & returns its result. In the event of an exception, default-val is returned instead of the exception.
(with-map-vals the-map items-vec & forms)
(with-map-vals &form &env the-map items-vec & forms)
Given a map like {:a 1 :b 2 :c 3} (such as generated by (vals->map a b c)
),
performs safe let
destructuring using grab
like:
(let [some-map {:a 1 :b 2 :c 3} } ] (with-map-vals some-map [a b c] (+ a b c))) ;=> 6
with-map-vals
is safe for typos since grab
will throw is the requrested map key is not present.
See vals->map
for simple creation of labelled data maps.
Given a map like {:a 1 :b 2 :c 3} (such as generated by `(vals->map a b c)`), performs safe `let` destructuring using `grab` like: (let [some-map {:a 1 :b 2 :c 3} } ] (with-map-vals some-map [a b c] (+ a b c))) ;=> 6 `with-map-vals` is safe for typos since `grab` will throw is the requrested map key is not present. See `vals->map` for simple creation of labelled data maps.
(with-nil-default default-val sample-val)
Returns sample-val
if not nil; else returns default-val
Returns `sample-val` if not nil; else returns `default-val`
(with-spy-enabled tag & forms)
(with-spy-enabled &form &env tag & forms)
(with-spy-indent & forms)
(with-spy-indent &form &env & forms)
Increments indentation level of all spy, spyx, or spyxx expressions within the body.
Increments indentation level of all spy, spyx, or spyxx expressions within the body.
(with-system-err-str & body)
(with-system-err-str &form &env & body)
Evaluates exprs in a context in which JVM System/err is bound to a fresh PrintStream. Returns the string created by any nested printing calls.
Evaluates exprs in a context in which JVM System/err is bound to a fresh PrintStream. Returns the string created by any nested printing calls.
(with-system-out-str & body)
(with-system-out-str &form &env & body)
Evaluates exprs in a context in which JVM System/out is bound to a fresh PrintStream. Returns the string created by any nested printing calls.
Evaluates exprs in a context in which JVM System/out is bound to a fresh PrintStream. Returns the string created by any nested printing calls.
(xbutlast coll)
Inputs: [coll :- [s/Any]] Returns: s/Any
Returns a vector of all but the last value in a list or vector. Throws if empty.
Inputs: [coll :- [s/Any]] Returns: s/Any Returns a vector of all but the last value in a list or vector. Throws if empty.
(xfirst coll)
Returns the first value in a list or vector. Throws if empty.
Returns the first value in a list or vector. Throws if empty.
(xfourth coll)
Returns the fourth value in a list or vector. Throws if (< len 4).
Returns the fourth value in a list or vector. Throws if (< len 4).
(xlast coll)
Inputs: [coll :- [s/Any]] Returns: s/Any
Returns the last value in a list or vector. Throws if empty.
Inputs: [coll :- [s/Any]] Returns: s/Any Returns the last value in a list or vector. Throws if empty.
(xrest coll)
Returns the last value in a list or vector. Throws if empty.
Returns the last value in a list or vector. Throws if empty.
(xreverse coll)
Returns a vector containing a sequence in reversed order. Throws if nil.
Returns a vector containing a sequence in reversed order. Throws if nil.
(xsecond coll)
Returns the second value in a list or vector. Throws if (< len 2).
Returns the second value in a list or vector. Throws if (< len 2).
(xtake n coll)
Returns the first n values from a collection. Returns map for map colls. Throws if empty.
Returns the first n values from a collection. Returns map for map colls. Throws if empty.
(xthird coll)
Returns the third value in a list or vector. Throws if (< len 3).
Returns the third value in a list or vector. Throws if (< len 3).
(xvec coll)
Inputs: [coll :- [s/Any]] Returns: [s/Any]
Converts a collection into a vector. Throws if given nil.
Inputs: [coll :- [s/Any]] Returns: [s/Any] Converts a collection into a vector. Throws if given nil.
(yield value)
Within a 'generator function' created by lazy-gen
, populates the
result lazy seq with the supplied value (a la Python). Returns the value.
Within a 'generator function' created by `lazy-gen`, populates the result lazy seq with the supplied value (a la Python). Returns the value.
(yield-all values)
Within a 'generator function' created by lazy-gen
, populates the
result lazy seq with each item from the supplied collection. Returns the collection.
Within a 'generator function' created by `lazy-gen`, populates the result lazy seq with each item from the supplied collection. Returns the collection.
(zip & args)
Zips together vectors producing a vector of tuples (like Python zip). Not lazy. Example:
(zip [:a :b :c] [1 2 3]) -> [ [:a 1] [:b 2] [:c 3] ]
***** WARNING - will hang for infinite length inputs *****
Zips together vectors producing a vector of tuples (like Python zip). Not lazy. Example: (zip [:a :b :c] [1 2 3]) -> [ [:a 1] [:b 2] [:c 3] ] ***** WARNING - will hang for infinite length inputs *****
(zip* context & colls)
Usage: (zip* context & colls) where context is a map with default values: {:strict true} Not lazy.
Usage: (zip* context & colls) where context is a map with default values: {:strict true} Not lazy.
(zip-1* context & colls)
Usage: (zip* context & colls) where context is a map with default values: {:strict true} Not lazy.
Usage: (zip* context & colls) where context is a map with default values: {:strict true} Not lazy.
(zip-lazy & colls)
Usage: (zip-lazy coll1 coll2 ...) (zip-lazy xs ys zs) -> [ [x0 y0 z0] [x1 y1 z1] [x2 y2 z2] ... ]
Returns a lazy result. Will truncate to the length of the shortest collection.
A convenience wrapper for (map vector coll1 coll2 ...)
.
Usage: (zip-lazy coll1 coll2 ...) (zip-lazy xs ys zs) -> [ [x0 y0 z0] [x1 y1 z1] [x2 y2 z2] ... ] Returns a lazy result. Will truncate to the length of the shortest collection. A convenience wrapper for `(map vector coll1 coll2 ...)`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close