The for loop is a common concept in computer languages.
When we want to apply the same logic (operations) to each element of a given array (vector or list in Clojure),
we apply the idea of a for loop to that.
In general, this involves incrementing (or decrementing) an index and performing a similar function on each element.
However, the way to implement a for loop varies from language to language.
Some use an index variable explicitly. Others use an iterator. Some use neither.
Clojure takes a very different approach.
for is categorized as a sequence operator, like
map(core function) or
More importantly, in Clojure,
for is used for list comprehension, which means it creates a list from a given list.
The syntax of the
for macro is:
(for [binding-form coll-expr filter-expr?] expr)
Try some examples.
Clojure from the ground up: macros, List comprehensions
Introdcution to Clojure, Bread and Butter Functions