Ok so put into my function an array an I keep so do some stuff to return a hashmap with a string as key and a list as value. I want to get only the final value and pass it as a parameter to another function.
Below is a java code which i am trying to translate into clojure
contents = documentContent.split("[ ,\\.]+");
for(int i = 0; i < contents.length; i++) {
String word = contents[i];
if(index.containsKey(word)) {
index.get(word).add(i);
} else {
List<Integer> list = new ArrayList<>();
list.add(i);
index.put(word, list);
}
}
Clojure code so far it somewhat works but i cant return the final value and pass it to another function
(defn indexFinder [contents]
(let [mem (def xs (atom {}))]
(map-indexed
(fn [index element]
(if (contains? @xs element)
(swap! xs assoc element (conj (@xs element) index))
(swap! xs assoc element [index])))
contents)))