Clojure Programming/Examples/API Examples/Macros

->
This is the "threading" operator.

this: is equivalent to:

NOTE: you do not need to insert ',,', since clojure treats them like whitespace, but marking the forms second position this way enhances readability.

However -> works on everything or expanded So one can also use macros and normal functions in ->, i.e. non-methods.

Here is an example that should make every devoted Programmer fall in love with lisp, if he compares it with equivalent Java code. Reading the name of the first entry in a zip file:

condp
The test expression (1 and 5 in the above example) is inserted as first parameter to the predicate function, the comparison expression (here a) as second. condp throws an java.lang.IllegalArgumentException if no clauses are matched in the above example. condp also allows to add a single default expression after the clauses whose value will be returned if no clauses matches.