(-<> expr & forms)
(-<> &form &env expr & forms)
Thread the results through the diamonds in forms
.
Threads the results of successive evaluations through the forms
by placing
the result from the preceding form into the next form at locations marked by
the diamond symbol <>
. Initially the value of expr
is bound to <>
before the first form is evaluated.
Note that (-<> expr ...)
is equivalent to (as-> expr <> ...)
.
Thread the results through the diamonds in `forms`. Threads the results of successive evaluations through the `forms` by placing the result from the preceding form into the next form at locations marked by the diamond symbol `<>`. Initially the value of `expr` is bound to `<>` before the first form is evaluated. Note that `(-<> expr ...)` is equivalent to `(as-> expr <> ...)`.
(<>-> & forms)
(<>-> &form &env & forms)
Bridge between an outer (-<> ...)
and inner (-> ...)
threading scopes.
Note that the entry value of the inner (-> ...)
threading scope is bound
to the simple symbol <>
throughout the inner scope. For example:
(-<> 3
(* <> 4) ; => 12
(<>->
(- 2) ; => 10
(* <>))) ; 12 still bound to <> => 120
Bridge between an outer `(-<> ...)` and inner `(-> ...)` threading scopes. Note that the entry value of the inner `(-> ...)` threading scope is bound to the simple symbol `<>` throughout the inner scope. For example: ```clojure (-<> 3 (* <> 4) ; => 12 (<>-> (- 2) ; => 10 (* <>))) ; 12 still bound to <> => 120 ```
(<>->> & forms)
(<>->> &form &env & forms)
Bridge between an outer (-<> ...)
and inner (->> ...)
threading scopes.
Note that the entry value of the inner (->> ...)
threading scope is bound
to the simple symbol <>
throughout the inner scope. For example:
(-<> 3
(* <> 4) ; => 12
(<>->>
(- 2) ; => -10
(* <>))) ; 12 still bound to <> => -120
Bridge between an outer `(-<> ...)` and inner `(->> ...)` threading scopes. Note that the entry value of the inner `(->> ...)` threading scope is bound to the simple symbol `<>` throughout the inner scope. For example: ```clojure (-<> 3 (* <> 4) ; => 12 (<>->> (- 2) ; => -10 (* <>))) ; 12 still bound to <> => -120 ```
(<>-bind binding-form & forms)
(<>-bind &form &env binding-form & forms)
Bind the threaded value within a diamond-threading scope.
Binds the value threaded in the outer diamond-threading scope to the symbols
in binding-form
destructuring the value as necessary. Continues the
diamond-threading scope by evaluating the forms
successively
threading the result of the previous evaluation into the next form at
locations marked by the diamond symbol <>
.
Bind the threaded value within a diamond-threading scope. Binds the value threaded in the outer diamond-threading scope to the symbols in `binding-form` destructuring the value as necessary. Continues the diamond-threading scope by evaluating the `forms` successively threading the result of the previous evaluation into the next form at locations marked by the diamond symbol `<>`.
(<>-cond & clauses)
(<>-cond &form &env & clauses)
Start an inner conditional context within a diamond-threading context.
Embeds a conditional diamond-threading context. Seeds the embedded context
with the threaded value from the enclosing diamond-threading context. See
also: harpoons.core/cond-<>
.
Start an inner conditional context within a diamond-threading context. Embeds a conditional diamond-threading context. Seeds the embedded context with the threaded value from the enclosing diamond-threading context. See also: `harpoons.core/cond-<>`.
(<>-do & body)
(<>-do &form &env & body)
Evaluate forms returning the last value within a diamond-threading scope.
Note that this an alias for do
. You might use this for the sake of
syntactic consistency. However in general you should prefer do
over
<>-do
.
Evaluate forms returning the last value within a diamond-threading scope. Note that this an alias for `do`. You might use this for the sake of syntactic consistency. However in general you should prefer `do` over `<>-do`.
(<>-fx! & body-forms)
(<>-fx! &form &env & body-forms)
Run a side-effect within a diamond-threading scope.
Evaluates body-forms
for their side effects and returns the value bound to
the simple symbol <>
.
Example:
(-<> (range 2 4)
(<>-fx! (prn :before <>)) ; ":before (2 3)"
(for [x <> y <>] (* x y))
(<>-fx! (prn :after <>)) ; ":after (4 6 6 9)"
(= <> '(4 6 6 9)))
; => true
Run a side-effect within a diamond-threading scope. Evaluates `body-forms` for their side effects and returns the value bound to the simple symbol `<>`. Example: ```clojure (-<> (range 2 4) (<>-fx! (prn :before <>)) ; ":before (2 3)" (for [x <> y <>] (* x y)) (<>-fx! (prn :after <>)) ; ":after (4 6 6 9)" (= <> '(4 6 6 9))) ; => true ```
(<>-let binding-form & body)
(<>-let &form &env binding-form & body)
Bind the value from the diamond-threading scode and evaluate the body forms.
Binds the value threaded in the outer diamond-threading scope to the symbols
in binding-form
destructuring the value as necessary. Evaluates the forms
in body
returning the value of the last.
Note that the value threaded in the outer diamond threading scope remain
bound to the symbol <>
.
Bind the value from the diamond-threading scode and evaluate the body forms. Binds the value threaded in the outer diamond-threading scope to the symbols in `binding-form` destructuring the value as necessary. Evaluates the forms in `body` returning the value of the last. Note that the value threaded in the outer diamond threading scope remain bound to the symbol `<>`.
(<>-non-nil & clauses)
(<>-non-nil &form &env & clauses)
Start an inner "or" short-circuiting context within a diamond-threading context.
Embeds a short-circuiting diamond-threading context that returns the first
non-nil value. Seeds the embedded context with the threaded value from the
enclosing diamond-threading context. See also: harpoons.core/non-nil-<>
.
Start an inner "or" short-circuiting context within a diamond-threading context. Embeds a short-circuiting diamond-threading context that returns the first non-nil value. Seeds the embedded context with the threaded value from the enclosing diamond-threading context. See also: `harpoons.core/non-nil-<>`.
(<>-some & clauses)
(<>-some &form &env & clauses)
Start an inner "and" short-circuiting context within a diamond-threading context.
Embeds a short-circuiting diamond-threading context that returns the first
nil value. Seeds the embedded context with the threaded value from the
enclosing diamond-threading context. See also: harpoons.core/some-<>
.
Start an inner "and" short-circuiting context within a diamond-threading context. Embeds a short-circuiting diamond-threading context that returns the first nil value. Seeds the embedded context with the threaded value from the enclosing diamond-threading context. See also: `harpoons.core/some-<>`.
(>-<> expr & body)
(>-<> &form &env expr & body)
Bridge between an outer left-threading and inner diamond-threading scopes.
Example: Listing the subjects belonging to categories A and B from the first trial of the study.
(-> study
:trials
(get 0)
:subjects
(>-<>
(group-by :category <>)
(concat (:a <>) (:b <>))))
Note that >-<>
is essentially equivalent to -<>
. It differs only by its
:style/indent
meta-data that guides more advanced editors in laying out
the source code.
Bridge between an outer left-threading and inner diamond-threading scopes. **Example:** Listing the subjects belonging to categories A and B from the first trial of the study. ```clojure (-> study :trials (get 0) :subjects (>-<> (group-by :category <>) (concat (:a <>) (:b <>)))) ``` Note that `>-<>` is essentially equivalent to `-<>`. It differs only by its `:style/indent` meta-data that guides more advanced editors in laying out the source code.
(>->> expr & forms)
(>->> &form &env expr & forms)
Bridge between an outer left-threading and inner right-threading scopes.
It is notable that this is essentially the same as the (->> ...)
threading
macro. You should use this version only when it is justified by emphasizing
the bridge point or by maintaining consistency with other bridge points.
Otherwise just use the standard (->> ...)
.
Example:
(-> monster
:inventory
(>->>
(filter #(> (:weight %) 10.0))
(sort-by :weight)
(take 5)))
Bridge between an outer left-threading and inner right-threading scopes. It is notable that this is essentially the same as the `(->> ...)` threading macro. You should use this version only when it is justified by emphasizing the bridge point or by maintaining consistency with other bridge points. Otherwise just use the standard `(->> ...)`. Example: ```clojure (-> monster :inventory (>->> (filter #(> (:weight %) 10.0)) (sort-by :weight) (take 5))) ```
(>-bind threaded-value binding-form & forms)
(>-bind &form &env threaded-value binding-form & forms)
Bind the threaded value within a left-threading scope.
Binds the value threaded in the outer left-threading scope to the symbols in
binding-form
destructuring the value as necessary. Continues the
left-threading scope by evaluating forms
successively and threading the
result from the previous evaluation through the first argument position
within the next form.
Bind the threaded value within a left-threading scope. Binds the value threaded in the outer left-threading scope to the symbols in `binding-form` destructuring the value as necessary. Continues the left-threading scope by evaluating `forms` successively and threading the result from the previous evaluation through the first argument position within the next form.
(>-cond expr & clauses)
(>-cond &form &env expr & clauses)
Start an inner conditional context within a left-threading context.
Embeds a conditional left-threading context. Seeds the embedded context
with the threaded value from the enclosing left-threading context. See
also: clojure.core/cond->
.
Note: This is effectively an alias for clojure.core/cond->
.
Start an inner conditional context within a left-threading context. Embeds a conditional left-threading context. Seeds the embedded context with the threaded value from the enclosing left-threading context. See also: `clojure.core/cond->`. Note: This is effectively an alias for `clojure.core/cond->`.
(>-fx! expr & body)
(>-fx! &form &env expr & body)
Run a side-effect within a left-threading scope.
Evaluates forms
for their side effect and returns expr
. The value of
expr
is bound to <>
and, thus, is accessible to forms
. The expression
expr
is evaluated once.
Example:
(= (-> {:foo 42}
(>-fx! (prn :before <>)) ; ":before {:foo 42}"
(assoc :bar 3.14)
(>-fx! (prn :after <>))) ; ":after {:foo 42, :bar 3.14}"
{:foo 42, :bar 3.14}) ; => true
Run a side-effect within a left-threading scope. Evaluates `forms` for their side effect and returns `expr`. The value of `expr` is bound to `<>` and, thus, is accessible to `forms`. The expression `expr` is evaluated once. Example: ```clojure (= (-> {:foo 42} (>-fx! (prn :before <>)) ; ":before {:foo 42}" (assoc :bar 3.14) (>-fx! (prn :after <>))) ; ":after {:foo 42, :bar 3.14}" {:foo 42, :bar 3.14}) ; => true ```
(>-let threaded-value binding-form & body)
(>-let &form &env threaded-value binding-form & body)
Bind the value from the left-threading scode and evaluate the body forms.
Binds the value threaded in the outer left-threading scope to the symbols in
binding-form
destructuring the value as necessary. Evaluates the forms in
body
returning the value of the last.
Bind the value from the left-threading scode and evaluate the body forms. Binds the value threaded in the outer left-threading scope to the symbols in `binding-form` destructuring the value as necessary. Evaluates the forms in `body` returning the value of the last.
(>-non-nil expr & threaded-forms)
(>-non-nil &form &env expr & threaded-forms)
Start an inner "or" short-circuiting context within a left-threading context.
Embeds a short-circuiting left-threading context that returns the first
non-nil value. Seeds the embedded context with the threaded value from the
enclosing left-threading context. See also: harpoons.core/non-nil->
.
Note: This is effectively an alias for harpoons.core/non-nil->
.
Start an inner "or" short-circuiting context within a left-threading context. Embeds a short-circuiting left-threading context that returns the first non-nil value. Seeds the embedded context with the threaded value from the enclosing left-threading context. See also: `harpoons.core/non-nil->`. Note: This is effectively an alias for `harpoons.core/non-nil->`.
(>-some expr & threaded-forms)
(>-some &form &env expr & threaded-forms)
Start an inner "and" short-circuiting context within a left-threading context.
Embeds a short-circuiting left-threading context that returns the first nil
value. Seeds the embedded context with the threaded value from the
enclosing left-threading context. See also: clojure.core/some->
.
Note: This is effectively an alias for clojure.core/some->
.
Start an inner "and" short-circuiting context within a left-threading context. Embeds a short-circuiting left-threading context that returns the first nil value. Seeds the embedded context with the threaded value from the enclosing left-threading context. See also: `clojure.core/some->`. Note: This is effectively an alias for `clojure.core/some->`.
(>>-<> & forms)
(>>-<> &form &env & forms)
Bridge between an outer (->> ...)
and inner (-<> ...)
threading scopes.
Bridge between an outer `(->> ...)` and inner `(-<> ...)` threading scopes.
(>>-> & forms)
(>>-> &form &env & forms)
Bridge between an outer (->> ...)
and inner (-> ...)
threading scopes.
Bridge between an outer `(->> ...)` and inner `(-> ...)` threading scopes.
(>>-bind binding-form & forms-and-threaded-value)
(>>-bind &form &env binding-form & forms-and-threaded-value)
Bind the threaded value within a right-threading context.
Binds the value threaded in the outer right-threading scope to the symbols
in binding-form
destructuring the value as necessary. Continues the
right-threading scope by evaluating forms
successively and threading the
result from the previous evaluation through the last argument position within
the next form.
Bind the threaded value within a right-threading context. Binds the value threaded in the outer right-threading scope to the symbols in `binding-form` destructuring the value as necessary. Continues the right-threading scope by evaluating `forms` successively and threading the result from the previous evaluation through the last argument position within the next form.
(>>-cond & clauses-and-expr)
(>>-cond &form &env & clauses-and-expr)
Start an inner conditional context within a right-threading context.
Embeds a conditional right-threading context. Seeds the embedded context
with the threaded value from the enclosing right-threading context. See
also: clojure.core/cond->>
.
Start an inner conditional context within a right-threading context. Embeds a conditional right-threading context. Seeds the embedded context with the threaded value from the enclosing right-threading context. See also: `clojure.core/cond->>`.
(>>-do & body-and-expr)
(>>-do &form &env & body-and-expr)
(>>-fx! expr)
(>>-fx! form & forms-and-expr)
(>>-fx! &form &env expr)
(>>-fx! &form &env form & forms-and-expr)
Run a side-effect within a right-threading scope.
Evaluates forms
for their side effects and returns expr
. The value of
expr
is bound to <>
and, thus, is accessible to forms
. The expression
expr
is evaluated once.
Examples:
(= (->> (range 5)
(>>-fx! (prn :before <>)) ; prints ":before (0 1 2 3 4)"
(filter even?)
(>>-fx! (prn :after <>))) ; prints ":after (0 2 4)"
'(0 2 4)) ; => true
Run a side-effect within a right-threading scope. Evaluates `forms` for their side effects and returns `expr`. The value of `expr` is bound to `<>` and, thus, is accessible to `forms`. The expression `expr` is evaluated once. Examples: ```clojure (= (->> (range 5) (>>-fx! (prn :before <>)) ; prints ":before (0 1 2 3 4)" (filter even?) (>>-fx! (prn :after <>))) ; prints ":after (0 2 4)" '(0 2 4)) ; => true ```
(>>-let binding-form & body-and-threaded-value)
(>>-let &form &env binding-form & body-and-threaded-value)
Bind the value from the right-threading scode and evaluate the body forms.
Binds the value threaded in the outer right-threading scope to the symbols
in binding-form
destructuring the value as necessary. Evaluates the forms
in body
returning the value of the last.
Bind the value from the right-threading scode and evaluate the body forms. Binds the value threaded in the outer right-threading scope to the symbols in `binding-form` destructuring the value as necessary. Evaluates the forms in `body` returning the value of the last.
(>>-non-nil & threaded-forms-and-expr)
(>>-non-nil &form &env & threaded-forms-and-expr)
Start an inner "or" short-circuiting context within a right-threading context.
Embeds a short-circuiting right-threading context that returns the first
non-nil value. Seeds the embedded context with the threaded value from the
enclosing right-threading context. See also: harpoons.core/non-nil->>
.
Start an inner "or" short-circuiting context within a right-threading context. Embeds a short-circuiting right-threading context that returns the first non-nil value. Seeds the embedded context with the threaded value from the enclosing right-threading context. See also: `harpoons.core/non-nil->>`.
(>>-some & threaded-forms-and-expr)
(>>-some &form &env & threaded-forms-and-expr)
Start an inner "and" short-circuiting context within a right-threading context.
Embeds a short-circuiting right-threading context that returns the first nil
value. Seeds the embedded context with the threaded value from the
enclosing right-threading context. See also: clojure.core/some->>
.
Start an inner "and" short-circuiting context within a right-threading context. Embeds a short-circuiting right-threading context that returns the first nil value. Seeds the embedded context with the threaded value from the enclosing right-threading context. See also: `clojure.core/some->>`.
(cond-<> expr & clauses)
(cond-<> &form &env expr & clauses)
Evaluate clauses
conditionally threading the results through the diamonds.
(cond-<> 10
false (+ <> 1) ; ignored
(= <> 10) (* <> <>))
; => 100
Evaluate `clauses` conditionally threading the results through the diamonds. ```clojure (cond-<> 10 false (+ <> 1) ; ignored (= <> 10) (* <> <>)) ; => 100 ```
(non-nil-<> expr & forms)
(non-nil-<> &form &env expr & forms)
Returns the first non-nil evaluation of forms
with expr
bound to <>
.
Returns the first non-nil evaluation of `forms` with `expr` bound to `<>`.
(non-nil-> expr & forms)
(non-nil-> &form &env expr & forms)
Return the first non-nil evaluation of forms
with expr
as the leftmost argument.
Threads expr
syntactically through the left-hand side of forms
and
evaluates the forms in a short-circuiting manner returning the first non-nil
result, if any. The expression expr
is evaluated at most once.
Examples:
(non-nil-> true) ; => nil
(non-nil-> nil identity nil? boolean) ; => true
(non-nil-> nil identity boolean nil?) ; => false
(non-nil-> {:foo 1, :bar 2} :xyzzy :bar :foo) ; => 2
(non-nil-> {:foo 1, :bar 2}
(get :xyzzy)
(get :bar)
(get :foo)) ; => 2
Return the first non-nil evaluation of `forms` with `expr` as the leftmost argument. Threads `expr` syntactically through the left-hand side of `forms` and evaluates the forms in a short-circuiting manner returning the first non-nil result, if any. The expression `expr` is evaluated at most once. Examples: ```clojure (non-nil-> true) ; => nil (non-nil-> nil identity nil? boolean) ; => true (non-nil-> nil identity boolean nil?) ; => false (non-nil-> {:foo 1, :bar 2} :xyzzy :bar :foo) ; => 2 (non-nil-> {:foo 1, :bar 2} (get :xyzzy) (get :bar) (get :foo)) ; => 2 ```
(non-nil->> expr & forms)
(non-nil->> &form &env expr & forms)
Return the first non-nil evaluation of forms
with expr
as the rightmost argument.
Threads expr
syntactically through the right-hand side of forms
and
evaluates the forms in a short-circuiting manner returning the first non-nil
result, if any. The expression expr
is evaluated at most once.
Return the first non-nil evaluation of `forms` with `expr` as the rightmost argument. Threads `expr` syntactically through the right-hand side of `forms` and evaluates the forms in a short-circuiting manner returning the first non-nil result, if any. The expression `expr` is evaluated at most once.
(some-<> expr & forms)
(some-<> &form &env expr & forms)
Thread the results through the diamonds in forms
short-circuiting at nil.
Thread the results through the diamonds in `forms` short-circuiting at nil.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close