4 ms·
Technically this is the transliteration of that ruby code: (def severity :mild) (def error_message "OH GOD! IT'S A DISASTER! WE'RE ") (if (= severi
by lgas 13y ago
Technically this is the transliteration of that ruby code:
(def severity :mild)
(def error_message "OH GOD! IT'S A DISASTER! WE'RE ")
(if (= severity :mild)
(def error_message (str error_message "MILDLY INCONVENIENCED!"))
(when (= severity :terrible)
(def error_message (str error_message "DOOOOOOOMED!"))))
And if we consider that a good transliteration then I'm not sure why this wouldn't suffice for the second one:
(def failed_protagonist_names [
"Larry Potter"
"Doreen the Explorer"
"The Incredible Bulk"
])
(def failed_protagonist_names
(assoc failed_protagonist_names 0 "Gary Potter"))
;; => ["Gary Potter" "Doreen the Explorer" "The Incredible Bulk"]
- nonrecursive 13y agoThis repl snippet should show that you're not actually changing a data structure in place. Rather, you're creating a new data structure and changing an existing binding: user=> (def a [1 2 3]) user=> (def b a) user=> (def a ["a" "b" "c"]) user=> a ["a" "b" "c"] user=> b [1 2 3]