fork download
  1. ; destructuring a vector
  2. (let [[a b] ["cheese" "cream"]]
  3. (println "Mix" a "with" b))
  4.  
  5. ; destructuring a map
  6. (let [{:keys [appliance time]} {:appliance "oven" :temp 180 :time 40}]
  7. (println "Cook in" appliance "for" time "minutes"))
  8.  
  9.  
  10. (def delicious-fish-recipe [["fish" "herbs"] {:appliance "pan" :time 7}])
  11.  
  12. (println delicious-fish-recipe)
  13.  
  14.  
  15. ; destructure vector and map
  16. (let [[[a b] {:keys [appliance time]}] delicious-fish-recipe]
  17. (println "Mix" a "with" b "and cook for" time "minutes in a" appliance))
  18.  
  19.  
  20. ; same, but in a function. I do not get this working...
  21. (def prepare [[a b] {:keys [appliance time]}]
  22. (println "Mix" a "with" b "and cook for" time "minutes in a" appliance))
  23.  
  24. (prepare delicious-fish-recipe)
  25.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty