Liking cljdoc? Tell your friends :D

harpoons.core


-<>clj/s≠macro

clj
(-<> expr & forms)
cljs
(-<> &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 <> ...)`.
source (clj)source (cljs)raw docstring

<>->clj/s≠macro

clj
(<>-> & forms)
cljs
(<>-> &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
```
source (clj)source (cljs)raw docstring

<>->>clj/s≠macro

clj
(<>->> & forms)
cljs
(<>->> &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
```
source (clj)source (cljs)raw docstring

<>-bindclj/s≠macro

clj
(<>-bind binding-form & forms)
cljs
(<>-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 `<>`.
source (clj)source (cljs)raw docstring

<>-condclj/s≠macro

clj
(<>-cond & clauses)
cljs
(<>-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-<>`.
source (clj)source (cljs)raw docstring

<>-doclj/s≠macro

clj
(<>-do & body)
cljs
(<>-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`.
source (clj)source (cljs)raw docstring

<>-fx!clj/s≠macro

clj
(<>-fx! & body-forms)
cljs
(<>-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
```
source (clj)source (cljs)raw docstring

<>-letclj/s≠macro

clj
(<>-let binding-form & body)
cljs
(<>-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 `<>`.
source (clj)source (cljs)raw docstring

<>-non-nilclj/s≠macro

clj
(<>-non-nil & clauses)
cljs
(<>-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-<>`.
source (clj)source (cljs)raw docstring

<>-someclj/s≠macro

clj
(<>-some & clauses)
cljs
(<>-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-<>`.
source (clj)source (cljs)raw docstring

>-<>clj/s≠macro

clj
(>-<> expr & body)
cljs
(>-<> &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.
source (clj)source (cljs)raw docstring

>->>clj/s≠macro

clj
(>->> expr & forms)
cljs
(>->> &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)))
```
source (clj)source (cljs)raw docstring

>-bindclj/s≠macro

clj
(>-bind threaded-value binding-form & forms)
cljs
(>-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.
source (clj)source (cljs)raw docstring

>-condclj/s≠macro

clj
(>-cond expr & clauses)
cljs
(>-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->`.
source (clj)source (cljs)raw docstring

>-doclj/s≠macro

clj
(>-do expr & body)
cljs
(>-do &form &env expr & body)
source (clj)source (cljs)

>-fx!clj/s≠macro

clj
(>-fx! expr & body)
cljs
(>-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
```
source (clj)source (cljs)raw docstring

>-letclj/s≠macro

clj
(>-let threaded-value binding-form & body)
cljs
(>-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.
source (clj)source (cljs)raw docstring

>-non-nilclj/s≠macro

clj
(>-non-nil expr & threaded-forms)
cljs
(>-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->`.
source (clj)source (cljs)raw docstring

>-someclj/s≠macro

clj
(>-some expr & threaded-forms)
cljs
(>-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->`.
source (clj)source (cljs)raw docstring

>>-<>clj/s≠macro

clj
(>>-<> & forms)
cljs
(>>-<> &form &env & forms)

Bridge between an outer (->> ...) and inner (-<> ...) threading scopes.

Bridge between an outer `(->> ...)` and inner `(-<> ...)` threading scopes.
source (clj)source (cljs)raw docstring

>>->clj/s≠macro

clj
(>>-> & forms)
cljs
(>>-> &form &env & forms)

Bridge between an outer (->> ...) and inner (-> ...) threading scopes.

Bridge between an outer `(->> ...)` and inner `(-> ...)` threading scopes.
source (clj)source (cljs)raw docstring

>>-bindclj/s≠macro

clj
(>>-bind binding-form & forms-and-threaded-value)
cljs
(>>-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.
source (clj)source (cljs)raw docstring

>>-condclj/s≠macro

clj
(>>-cond & clauses-and-expr)
cljs
(>>-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->>`.
source (clj)source (cljs)raw docstring

>>-doclj/s≠macro

clj
(>>-do & body-and-expr)
cljs
(>>-do &form &env & body-and-expr)
source (clj)source (cljs)

>>-fx!clj/s≠macro

clj
(>>-fx! expr)
(>>-fx! form & forms-and-expr)
cljs
(>>-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
```
source (clj)source (cljs)raw docstring

>>-letclj/s≠macro

clj
(>>-let binding-form & body-and-threaded-value)
cljs
(>>-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.
source (clj)source (cljs)raw docstring

>>-non-nilclj/s≠macro

clj
(>>-non-nil & threaded-forms-and-expr)
cljs
(>>-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->>`.
source (clj)source (cljs)raw docstring

>>-someclj/s≠macro

clj
(>>-some & threaded-forms-and-expr)
cljs
(>>-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->>`.
source (clj)source (cljs)raw docstring

cond-<>clj/s≠macro

clj
(cond-<> expr & clauses)
cljs
(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
```
source (clj)source (cljs)raw docstring

non-nil-<>clj/s≠macro

clj
(non-nil-<> expr & forms)
cljs
(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 `<>`.
source (clj)source (cljs)raw docstring

non-nil->clj/s≠macro

clj
(non-nil-> expr & forms)
cljs
(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
```
source (clj)source (cljs)raw docstring

non-nil->>clj/s≠macro

clj
(non-nil->> expr & forms)
cljs
(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.
source (clj)source (cljs)raw docstring

some-<>clj/s≠macro

clj
(some-<> expr & forms)
cljs
(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.
source (clj)source (cljs)raw docstring

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

× close