Liking cljdoc? Tell your friends :D

threading.core


*pp-lazy-max*clj

source

-•cljmacro

(-• & forms)

See •-. Threads like ->.

See [[•-]].
Threads like `->`.
sourceraw docstring

-••cljmacro

(-•• & forms)

See •-. Threads like ->>.

See [[•-]].
Threads like `->>`.
sourceraw docstring

<-cljmacro

(<- 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 `->`.
sourceraw docstring

<<-cljmacro

(<<- 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 `->>`.
sourceraw docstring

>-cljmacro

(>- 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.
sourceraw docstring

>->cljmacro

(>-> threaded-expr expr)

Shorthand for `(>- (-> ...).

Shorthand for `(>- (-> ...).
sourceraw docstring

>->>cljmacro

(>->> threaded-expr expr)

Shorthand for `(>- (->> ...).

Shorthand for `(>- (->> ...).
sourceraw docstring

>-argscljmacro

(>-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 `->`.
sourceraw docstring

>>-cljmacro

(>>- 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.
sourceraw docstring

>>->cljmacro

(>>-> expr threaded-expr)

Shorthand for `(>>- (-> ...).

Shorthand for `(>>- (-> ...).
sourceraw docstring

>>->>cljmacro

(>>->> expr threaded-expr)

Shorthand for `(>>- (->> ...).

Shorthand for `(>>- (->> ...).
sourceraw docstring

>>-argscljmacro

(>>-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 `->>`.
sourceraw docstring

and->cljmacro

(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 `->`.
sourceraw docstring

and->>cljmacro

(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 `->>`.
sourceraw docstring

binding->cljmacro

(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 `->`.
sourceraw docstring

binding->>cljmacro

(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 `->>`.
sourceraw docstring

defthreadingcljmacro

(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.
sourceraw docstring

if->cljmacro

(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 `->`.
sourceraw docstring

if->>cljmacro

(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 `->>`.
sourceraw docstring

if-not->cljmacro

(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 `->`.
sourceraw docstring

if-not->>cljmacro

(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 `->>`.
sourceraw docstring

juxt->cljmacro

(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 `->`.
sourceraw docstring

juxt->>cljmacro

(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 `->>`.
sourceraw docstring

let->cljmacro

(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 `->`.
sourceraw docstring

let->>cljmacro

(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 `->>`.
sourceraw docstring

map->cljmacro

(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 `->`.
sourceraw docstring

map->>cljmacro

(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 `->>`.
sourceraw docstring

map-keys->cljmacro

(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 `->`.
sourceraw docstring

map-keys->>cljmacro

(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 `->>`.
sourceraw docstring

map-vals->cljmacro

(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 `->`.
sourceraw docstring

map-vals->>cljmacro

(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 `->>`.
sourceraw docstring

mapcat->cljmacro

(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 `->`.
sourceraw docstring

mapcat->>cljmacro

(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 `->>`.
sourceraw docstring

mapv->cljmacro

(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 `->`.
sourceraw docstring

mapv->>cljmacro

(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 `->>`.
sourceraw docstring

not->cljmacro

(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 `->`.
sourceraw docstring

not->>cljmacro

(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 `->>`.
sourceraw docstring

or->cljmacro

(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 `->`.
sourceraw docstring

or->>cljmacro

(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 `->>`.
sourceraw docstring

pp->cljmacro

(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`.
sourceraw docstring

pp->>cljmacro

(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`.
sourceraw docstring

tapcljmacro

(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
```
sourceraw docstring

tap->cljmacro

(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 `->`.
sourceraw docstring

tap->>cljmacro

(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 `->>`.
sourceraw docstring

when->cljmacro

(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 `->`.
sourceraw docstring

when->>cljmacro

(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 `->>`.
sourceraw docstring

when-not->cljmacro

(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 `->`.
sourceraw docstring

when-not->>cljmacro

(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 `->>`.
sourceraw docstring

•-cljmacro

(•- first-expr second-expr)

Stores expr on the stack then threads it to 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 then threads it to `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.
sourceraw docstring

••-cljmacro

(••- first-expr second-expr)

Stores expr on the stack then threads it to 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 then threads it to `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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close