-
compute
1+1 -
call the function
getwith arguments"ciao"and1 -
compute
(3+4/5)*6 -
define a vector with the elements
1,"hello"andtrue -
define a vector that contains the keywords
:diffand:merge -
define a map with the key
1is associated with the value"hello"and the key:keywith the value[13 7] -
use
defto define a variablemy-mapthat refers to the map{1 2}. Use theassocfunction to add a new key and value tomy-map. What does theassoccall return? What is the value ofmy-mapafter the call? -
use
conjto add a value to a vector -
use the function
getto get the second element from a vector -
use the function
getto get the value of a key from a map -
get the value of a key from a map using the map itself as a function
-
get the value of a key from a map using a keyword as a function
-
use the function
get-into return the value:treasurefrom the value:{:description "cave" :crossroads [{:contents :monster} nil {:contents [:trinket :treasure]}]} -
use
defnto define a function hello that works like this:(hello) ==> "hello!" -
define a function
doublethat works like this:(double 5) ==> 10,(double 1) ==> 2 -
add a docstring to the function
double. Then show it using(doc double). -
challenge! implement a
factorialfunction using recursion.
-
use the
letstructure to define a local variablebwith the value"bork". Then use thestrfunction to combine twobs into"borkbork". -
define a function
small?that returnstruefor numbers under 100 -
define a function
message!that has three cases:(message! :boink) ==> "Boink!" (message! :pig) ==> "oink" (message! :ping) ==> "pong"
-
reimplement
message!using theifstructure -
reimplement
message!using thecondstructure -
reimplement
message!using thecasestructure -
challenge! use the
loopstructure to add1to an empty vector until it has 10 elements. Note:loopcan be hard. Don't get stuck on this exercise!
-
increment all the numbers in the vector
[4 7 9 10]by one. Use themapfunktiota. Hint: the functioninc -
do the same as in the previous exercise, but leave only the even results in the vector. Use the functions
filterandeven? -
use the
forstructure to go through this vector of maps:[{:id 1 :value 7.0} {:id 2 :value 3.0} {:id 7 :value 1.1}]and return a sequence of the
:values:(7.0 3.0 1.1) -
Use the function
update-into change 3 into 4 in the value below:{:shops [:shop-1] :customers [{:id "Pekka" :account {:balance 3}}]} -
challenge! use the
reducefunction to combine a vector of maps like this:(combine [{:a 1 :b 2} {:c 3} {:d 4 :e 5}]) ==> {:a 1 :b 2 :c 3 :d 4 :e 5}