On this page:
:  >
f>
l>
->
->>

3.12 Pipe/Threading Operators

procedure

(:> initial-value fns ...)  any

  initial-value : any
  fns : fn?
The forward pipe operator. Given a value and a series of single-argument functions, applies them in order from left to right and returns the resulting value.

Example:
> (:> 5 inc dec sgn)

1

syntax

(f> fun args* ...)

A currying macro. Expands into an anonymous function that takes a single argument, and inserts it as the first argument of fun, followed by the remaining args*.

Example:
> (:> '(1 2) (f> append '(3 4)))

'(1 2 3 4)

syntax

(l> fun args* ...)

The inverse of f>. Returns a function whose argument is placed as the last argument to the given fun.

Example:
> (:> '(1 2) (l> append '(3 4)))

'(3 4 1 2)

syntax

(-> initial-value (fun args* ...) ...)

The first-argument threading macro. Works similarly to :>, except that it automatically applies f> to each listed form following the initial value.

Example:
> (-> '(1 2 3 4)
      (left 2)
      (append '(a b)))

'(1 2 a b)

syntax

(->> initial-value (fun args* ...) ...)

The last-argument (as in l>) version of ->.

Example:
> (->> '(1 2 3 4)
       (map (fn (x) (* x x)))
       (append '(a b)))

'(a b 1 4 9 16)