I'm learning Clojure at the moment, and I'm having difficulty getting into the functional mindset.
I have a map that I am trying to populate from the command line. This is the code I have so far:
(ns dungeonworld.core
(:gen-class))
(def pc {:Name ""
:Class ""
:Race ""
:Look ""
:Str 0
:Dex 0
:Con 0
:Wis 0
:Int 0
:Cha 0
})
(defn getVals
[]
(println "Enter Name: ")
(assoc pc :Name (read-line))
(println "Enter Class: ")
(assoc pc :Race (read-line))
(println "Enter Look: ")
(assoc pc :Look (read-line)))
(defn -main
"Create a Dungeon World character map"
[& args]
(getVals))
However it only updates the last entry (:Look).
Questions: How do I achieve what I want to achieve in a more functional, Clojure-y way, and how come it only updates the last map element? Is a map the right type to use?
Many thanks in advance!