3 Basic Constructs

 

This chapter groups together some of the most important constructs in Clojure (and similarly other programming languages): conditional branching, iteration and local scope definition. There are other aspects that could be added to this category like namespaces, variables or functions but because of their complexity they have been dedicated a separate chapter.

You might be surprised to see things like conditionals, switch statements or loops as being part of the standard library. But Clojure (as many other Lisps before) builds on a small core of primitives called special forms and many functions that would be considered reserved words in other languages are defined (or refined) in the standard library. This is the reason why the Clojure standard library could be compared to a language specification.

3.1  Lexical Binding

3.1.1  let and let*

3.1.2  if-let, when-let, if-some and when-some

3.1.3  letfn and letfn*

3.2  Boolean and Bitwise Operators

3.2.1  not

3.2.2  and, or

3.2.3  bit-and and bit-or

3.3  Conditional Branching

3.3.1  if, if-not, when and when-not

3.3.2  cond

3.3.3  condp

3.3.4  case

3.4  Iteration and loops

3.4.1  loop, recur and loop*

3.4.2  range

3.4.3  for

3.4.4  while

3.4.5  dotimes

3.5  A Glimpse of Collection Processing

3.5.1  first, second and last

3.5.2  map and map-indexed

3.5.3  filter and remove

3.5.4  reduce and reductions

sitemap