let - local assignment

We can assign a name to a simple value or a collection using the let function

Names that we assign can only be used within the let function.

(let [title     "A local shop"
      sub-title "for local people"]
  (str title ", " sub-title))

How many fruit

Assign the names of fruit to the number of fruit you have.

Then return the total number of fruit

Reveal answer...

We have 9 apples and 15 oranges. So in total we have 24 fruit in total

(let [apples   9
      oranges 15]
  (+ apples oranges))

;; => 24

results matching ""

    No results matching ""