(-•• & forms)
See •-
.
Threads like ->>
.
See [[•-]]. Threads like `->>`.
(<- first-expr second-expr)
As an equivalent to constantly
, the anti-threading arrow is used to
return an arbitrary value from a threading slot.
The threaded expression will be evaluated although its value will be
discarded.
To be used in the context of a form threading in the style of ->
.
As an equivalent to `constantly`, the anti-threading arrow is used to return an arbitrary value from a threading slot. The threaded expression will be evaluated although its value will be discarded. To be used in the context of a form threading in the style of `->`.
(<<- first-expr second-expr)
As an equivalent to constantly
, the anti-threading arrow is used to
return an arbitrary value from a threading slot.
The threaded expression will be evaluated although its value will be
discarded.
To be used in the context of a form threading in the style of ->>
.
As an equivalent to `constantly`, the anti-threading arrow is used to return an arbitrary value from a threading slot. The threaded expression will be evaluated although its value will be discarded. To be used in the context of a form threading in the style of `->>`.
(>- first-expr second-expr)
A threading fletching used to change the position at which the threaded form will be injected in the threading slots of the threading form. Transitions from a thread-first to a thread-last threading style.
A threading fletching used to change the position at which the threaded form will be injected in the threading slots of the threading form. Transitions from a thread-first to a thread-last threading style.
(>-> threaded-expr expr)
Shorthand for `(>- (-> ...).
Shorthand for `(>- (-> ...).
(>->> threaded-expr expr)
Shorthand for `(>- (->> ...).
Shorthand for `(>- (->> ...).
(>-args first-expr second-expr)
Fletching that uses the arrow in the threading form to thread the
expression in all subforms of its subform. form
must have only one subform.
Fletching that moves the arrow in the threading form inside its subform's
arguments. The threading arrow must have only one subform.
Will thread the expr into the subforms with ->
.
Fletching that uses the arrow in the threading form to thread the expression in all subforms of its subform. `form` must have only one subform. Fletching that moves the arrow in the threading form inside its subform's arguments. The threading arrow must have only one subform. Will thread the expr into the subforms with `->`.
(>>- first-expr second-expr)
A threading fletching used to change the position at which the threaded form will be injected in the threading slots of the threading form. Transitions from a thread-last to a thread-first threading style.
A threading fletching used to change the position at which the threaded form will be injected in the threading slots of the threading form. Transitions from a thread-last to a thread-first threading style.
(>>-> expr threaded-expr)
Shorthand for `(>>- (-> ...).
Shorthand for `(>>- (-> ...).
(>>->> expr threaded-expr)
Shorthand for `(>>- (->> ...).
Shorthand for `(>>- (->> ...).
(>>-args first-expr second-expr)
Fletching that uses the arrow in the threading form to thread the
expression in all subforms of its subform. form
must have only one subform.
Fletching that moves the arrow in the threading form inside its subform's
arguments. The threading arrow must have only one subform.
Will thread the expr into the subforms with ->>
.
Fletching that uses the arrow in the threading form to thread the expression in all subforms of its subform. `form` must have only one subform. Fletching that moves the arrow in the threading form inside its subform's arguments. The threading arrow must have only one subform. Will thread the expr into the subforms with `->>`.
(and-> expr & forms)
Threads expr
through each form halting on a nil
or false
result.
Threads like ->
.
Threads `expr` through each form halting on a `nil` or `false` result. Threads like `->`.
(and->> expr & forms)
Threads expr
through each form halting on a nil
or false
result.
Threads like ->>
.
Threads `expr` through each form halting on a `nil` or `false` result. Threads like `->>`.
(binding-> expr bindings & body)
Threads expr
through each bound expression then through each form in
body
like binding
.
Threads like ->
.
Threads `expr` through each bound expression then through each form in `body` like `binding`. Threads like `->`.
(binding->> expr bindings & body)
Threads expr
through each bound expression then through each form in
body
like binding
.
Threads like ->>
.
Threads `expr` through each bound expression then through each form in `body` like `binding`. Threads like `->>`.
(defthreading & args)
Defines a threading arrow with variants.
Each variant is defined by a sequence like (name docstring? opts?)
.
The name of each defined threading arrow will consist in the
variant symbol (usually ->
and ->>
) prefixed by thread-name
if provided.
Same goes for each arrow docstring: it will be prefixed with
doc-prefix
if provided.
The body
will have access to some local variables defined under
the hood:
&threading-variant
(mapped to the variant's name)&threading-opts
(mapped to the variant's opts map if provided)Keep in mind defthreading
defines macros: the body should
return Clojure code, not runtime values.
Example:
Consider this definition of tap
with a custom ->debug
threading variant:
(defmacro ->debug [& forms]
`(-> ~@forms))
(defthreading tap
"Some documentation."
[-> "Some sufix for the documentation."
->> "Another documentation complement"
->debug {:debug true}] ;; No documentation here
[expr & forms]
`(let [result# ~expr]
(when (:debug ~&threading-opts)
(println "debug->:" result#))
(~&threading-variant result# ~@forms)
result#))
(tap->debug 1 (println ": perform some side-effect"))
;; debug->: 1
;; 1 : perform some side-effect.
;; => 1
Remarks:
name
is optional.name
must be followed by the :prefix
arrow-position
to
define fletchings.Defines a threading arrow with variants. Each variant is defined by a sequence like `(name docstring? opts?)`. The name of each defined threading arrow will consist in the variant symbol (usually `->` and `->>`) prefixed by `thread-name` if provided. Same goes for each arrow docstring: it will be prefixed with `doc-prefix` if provided. The `body` will have access to some local variables defined under the hood: - `&threading-variant` (mapped to the variant's name) - `&threading-opts` (mapped to the variant's opts map if provided) Keep in mind `defthreading` defines macros: the body should return Clojure code, not runtime values. Example: Consider this definition of [[tap]] with a custom `->debug` threading variant: ```clojure (defmacro ->debug [& forms] `(-> ~@forms)) (defthreading tap "Some documentation." [-> "Some sufix for the documentation." ->> "Another documentation complement" ->debug {:debug true}] ;; No documentation here [expr & forms] `(let [result# ~expr] (when (:debug ~&threading-opts) (println "debug->:" result#)) (~&threading-variant result# ~@forms) result#)) (tap->debug 1 (println ": perform some side-effect")) ;; debug->: 1 ;; 1 : perform some side-effect. ;; => 1 ``` Remarks: - `name` is optional. - `name` must be followed by the `:prefix` `arrow-position` to define fletchings.
(if-> expr test then)
(if-> expr test then else)
Threads expr
through test
then then
or else
. If else
is
not provided, returns expr
when test
fails.
Threads like ->
.
Threads `expr` through `test` then `then` or `else`. If `else` is not provided, returns `expr` when `test` fails. Threads like `->`.
(if->> expr test then)
(if->> expr test then else)
Threads expr
through test
then then
or else
. If else
is
not provided, returns expr
when test
fails.
Threads like ->>
.
Threads `expr` through `test` then `then` or `else`. If `else` is not provided, returns `expr` when `test` fails. Threads like `->>`.
(if-not-> expr test then)
(if-not-> expr test then else)
Threads expr
through test
then then
or else
. If else
is
not provided, returns expr
when test
fails.
Threads like ->
.
Threads `expr` through `test` then `then` or `else`. If `else` is not provided, returns `expr` when `test` fails. Threads like `->`.
(if-not->> expr test then)
(if-not->> expr test then else)
Threads expr
through test
then then
or else
. If else
is
not provided, returns expr
when test
fails.
Threads like ->>
.
Threads `expr` through `test` then `then` or `else`. If `else` is not provided, returns `expr` when `test` fails. Threads like `->>`.
(juxt-> expr & forms)
Threads expr
through each form individually, collecting the results in a
lazy sequence.
Threads like ->
.
Threads `expr` through each form individually, collecting the results in a lazy sequence. Threads like `->`.
(juxt->> expr & forms)
Threads expr
through each form individually, collecting the results in a
lazy sequence.
Threads like ->>
.
Threads `expr` through each form individually, collecting the results in a lazy sequence. Threads like `->>`.
(let-> expr bindings & body)
Threads expr
through each bound expression then through each form in
body
like let
.
Threads like ->
.
Threads `expr` through each bound expression then through each form in `body` like `let`. Threads like `->`.
(let->> expr bindings & body)
Threads expr
through each bound expression then through each form in
body
like let
.
Threads like ->>
.
Threads `expr` through each bound expression then through each form in `body` like `let`. Threads like `->>`.
(map-> expr & forms)
For an expr
that will yield a sequence, threads each of its values
through the forms
.
Threads like ->
.
For an `expr` that will yield a sequence, threads each of its values through the `forms`. Threads like `->`.
(map->> expr & forms)
For an expr
that will yield a sequence, threads each of its values
through the forms
.
Threads like ->>
.
For an `expr` that will yield a sequence, threads each of its values through the `forms`. Threads like `->>`.
(map-keys-> expr & forms)
For an expr
that will yield an associative structure, threads each of its
keys through the forms
.
Threads like ->
.
For an `expr` that will yield an associative structure, threads each of its keys through the `forms`. Threads like `->`.
(map-keys->> expr & forms)
For an expr
that will yield an associative structure, threads each of its
keys through the forms
.
Threads like ->>
.
For an `expr` that will yield an associative structure, threads each of its keys through the `forms`. Threads like `->>`.
(map-vals-> expr & forms)
For an expr
that will yield an associative structure, threads each of its
values through the forms
.
Threads like ->
.
For an `expr` that will yield an associative structure, threads each of its values through the `forms`. Threads like `->`.
(map-vals->> expr & forms)
For an expr
that will yield an associative structure, threads each of its
values through the forms
.
Threads like ->>
.
For an `expr` that will yield an associative structure, threads each of its values through the `forms`. Threads like `->>`.
(mapcat-> expr & forms)
For an expr
that will yield a sequence, threads each of its values
through the forms
then returns the individual results concatenated together
as a seq.
Threads like ->
.
For an `expr` that will yield a sequence, threads each of its values through the `forms` then returns the individual results concatenated together as a seq. Threads like `->`.
(mapcat->> expr & forms)
For an expr
that will yield a sequence, threads each of its values
through the forms
then returns the individual results concatenated together
as a seq.
Threads like ->>
.
For an `expr` that will yield a sequence, threads each of its values through the `forms` then returns the individual results concatenated together as a seq. Threads like `->>`.
(mapv-> expr & forms)
For an expr
that will yield a sequence, threads each of its values
through the forms
. Returns the transformed sequence as a vector.
Threads like ->
.
For an `expr` that will yield a sequence, threads each of its values through the `forms`. Returns the transformed sequence as a vector. Threads like `->`.
(mapv->> expr & forms)
For an expr
that will yield a sequence, threads each of its values
through the forms
. Returns the transformed sequence as a vector.
Threads like ->>
.
For an `expr` that will yield a sequence, threads each of its values through the `forms`. Returns the transformed sequence as a vector. Threads like `->>`.
(not-> expr & forms)
Threads expr
through the forms
then returns the negated result.
Threads like ->
.
Threads `expr` through the `forms` then returns the negated result. Threads like `->`.
(not->> expr & forms)
Threads expr
through the forms
then returns the negated result.
Threads like ->>
.
Threads `expr` through the `forms` then returns the negated result. Threads like `->>`.
(or-> expr & forms)
Threads expr
through each expr halting on a non nil
or false
result.
Threads like ->
.
Threads `expr` through each expr halting on a non `nil` or `false` result. Threads like `->`.
(or->> expr & forms)
Threads expr
through each expr halting on a non nil
or false
result.
Threads like ->>
.
Threads `expr` through each expr halting on a non `nil` or `false` result. Threads like `->>`.
(pp-> f & forms)
Like ->
, but prints a debug statement for f
and each expr in forms
.
Like `->`, but prints a debug statement for `f` and each expr in `forms`.
(pp->> f & forms)
Like ->>
, but prints a debug statement for f
and each expr in forms
.
Like `->>`, but prints a debug statement for `f` and each expr in `forms`.
(tap expr & body)
Evaluates expressions in order returning the value of the first. Will thread the first expression into any immediate threading subexpressions.
(tap 123
(println "yo")
(some-> inc println))
; yo
; 124
; => 123
Evaluates expressions in order returning the value of the first. Will thread the first expression into any immediate threading subexpressions. ```clojure (tap 123 (println "yo") (some-> inc println)) ; yo ; 124 ; => 123 ```
(tap-> expr & forms)
Threads expr
through forms
then returns the value of
the initial expression.
Threads like ->
.
Threads `expr` through `forms` then returns the value of the initial expression. Threads like `->`.
(tap->> expr & forms)
Threads expr
through forms
then returns the value of
the initial expression.
Threads like ->>
.
Threads `expr` through `forms` then returns the value of the initial expression. Threads like `->>`.
(when-> expr test & forms)
Threads expr
through test
then the rest of the forms
if it succeeds.
Returns expr
otherwise.
Threads like ->
.
Threads `expr` through `test` then the rest of the `forms` if it succeeds. Returns `expr` otherwise. Threads like `->`.
(when->> expr test & forms)
Threads expr
through test
then the rest of the forms
if it succeeds.
Returns expr
otherwise.
Threads like ->>
.
Threads `expr` through `test` then the rest of the `forms` if it succeeds. Returns `expr` otherwise. Threads like `->>`.
(when-not-> expr test & forms)
Threads expr
through test
then the rest of the forms
if it fails.
Returns expr
otherwise.
Threads like ->
.
Threads `expr` through `test` then the rest of the `forms` if it fails. Returns `expr` otherwise. Threads like `->`.
(when-not->> expr test & forms)
Threads expr
through test
then the rest of the forms
if it fails.
Returns expr
otherwise.
Threads like ->>
.
Threads `expr` through `test` then the rest of the `forms` if it fails. Returns `expr` otherwise. Threads like `->>`.
(•- first-expr second-expr)
Stores expr
on the stack and returns the computation represented by
form
. In form
, any deep occurence of the -•
arrow will thread
this value stored on the stack to its inner expressions.
Note that -•
can only be used within the body of a •-
form.
Must be used in the context of a thread-first arrow.
Stores `expr` on the stack and returns the computation represented by `form`. In `form`, any deep occurence of the `-•` arrow will thread this value stored on the stack to its inner expressions. Note that `-•` can only be used within the body of a `•-` form. Must be used in the context of a thread-first arrow.
(••- first-expr second-expr)
Stores expr
on the stack and returns the computation represented by
form
. In form
, any deep occurence of the -•
arrow will thread
this value stored on the stack to its inner expressions.
Note that -•
can only be used within the body of a •-
form.
Must be used in the context of a thread-last arrow.
Stores `expr` on the stack and returns the computation represented by `form`. In `form`, any deep occurence of the `-•` arrow will thread this value stored on the stack to its inner expressions. Note that `-•` can only be used within the body of a `•-` form. Must be used in the context of a thread-last arrow.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close