Exercise 1: Compute 1 + 1
Exercise 2: Call the function get with arguments "hello" and 1
Exercise 3: Compute (3 + 4 / 5) * 6
Exercise 4: Define a vector with the elements 2, "nice" and true
# or
Exercise 5: Define a vector that contains the keywords :key and :word
# or
Exercise 6: Define a map with the key :name associated with the value "Frederick"
# or
Exercise 7: Use def to define a variable my-map that refers to the map {:1 2}.
Use the put function to add a new key and value to my-map.
- What does the
putcall return? - What is the value of
my-mapafter the call?
Exercise 8: Use push to add a value to a vector
Exercise 9: Use the function get to get the second element from a vector
Exercise 10: Use the function get to get the value of a key from a map
Exercise 11: Get the value of a key from a map using the map itself as a function
Exercise 12: Get the value of a key from a map using a keyword as a function
Exercise 13: Use the function get-in to return the value :treasure from the map:
Exercise 14: Use defn to define a function hello that works like this:
(hello) ==> "hello!"
Exercise 15: Define a function double that works like this: (double 5) ==> 10
Exercise 16: Add a docstring to the function double. Then show it using (doc double)
Exercise 17: Implement a factorial function using recursion.