Skip to content

clojure.core/->>

View this page on ClojureDocs

Type: macro Added: Clojure 1.1 Examples: 11 Runnable: 7
([x & forms])

Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc.

Examples

by tomoj on
by BertrandDechoux on
by deddu on
by rsachdeva on . May have evaluation errors.
by huahaiy on . May have evaluation errors.
by huahaiy on . May have evaluation errors.
by rafmagana on . May have evaluation errors.
by ibercode on
by ibercode on
by ningDr on
by harelix on

Note by Jacolyte

I'm getting: Exception in thread "main" java.lang.Exception: Unable to resolve symbol: ->> in this context (11.clj:25)

It's also extremely hard to Google this method. It'd be nice if there was a non-symbol name for this that one could search for.

Update

The name of this operator is called a thrush.

Note by steveminer

See also -> which is similar but threads the first expr as the second argument of the forms.

Note by Jacolyte

My error was due to using an old version of Clojure. I was using 1.0.0.

Note by nmichel

There is something I don't get : in the case "form" is a seq, why should we write ... (with-meta `(~(first form) ~@(next form) ~x) (meta form))

and not ... (with-meta `(~@form ~x) (meta form))

as items order in "form" is not changed ?

Note by nzl-nott

"See also -> which is similar but threads the first expr as the second argument of the forms."

This is incorrect, it is not the second ARGUMENT, but the second ITEM.

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.