Note that there are some explanatory texts on larger screens.

plurals
  1. POClojure Inconsistent results in clojure during executions of a function
    primarykey
    data
    text
    <p>Clojure question</p> <p>I have written the following function in clojure: In the first loop it iterates a list of maps and creates a map. Then the second loop iterates a list, matches data from the map previously created and a vector and returns a new map. However, different runs with the same data produce diffenet results. See below.</p> <pre><code>(defn resolve-case-per-period "Constructs a map by matching data existing in input parameter vectors" [dd case-details periods] (let [cases ((fn [in] (loop [case-details in, result-map {}] (if (= (count case-details) 0) result-map (recur (rest case-details) (assoc result-map (:priority (first case-details)) (:caseid (first case-details))))))) case-details) periods periods] (info "Mapping cases to periods step 1 completed " cases) (loop [periods periods, result-map {}] (if (= (count periods) 0) result-map (recur (rest periods) (conj result-map { (str (:period (first periods))) (get cases (:priority (first periods)))})))))) </code></pre> <p>The returned output is of a map like the following:</p> <pre><code>{31-10-10 20 10020101030122036M, 31-10-10 10 10020101030122036M, 31-10-10 21 10020101030122036M, 30-10-10 21 10020101030200157M, 31-10-10 00 10020101030122036M, 31-10-10 11 10020101030122036M, 31-10-10 22 10020101031112152M, 30-10-10 22 10020101030122036M, 31-10-10 01 10020101030122036M, 31-10-10 12 10020101030122036M, 30-10-10 23 10020101030122036M, 31-10-10 02 10020101030122036M, 31-10-10 13 10020101030122036M, 31-10-10 03 10020101030122036M, 31-10-10 14 10020101030122036M, 31-10-10 04 10020101030122036M, 31-10-10 15 10020101030122036M, 31-10-10 05 10020101030122036M, 31-10-10 16 10020101030122036M, 31-10-10 06 10020101030122036M, 31-10-10 17 10020101030122036M, 31-10-10 07 10020101030122036M, 31-10-10 18 10020101030122036M, 31-10-10 08 10020101030122036M, 31-10-10 19 10020101030122036M, 31-10-10 09 10020101030122036M} </code></pre> <p>Executing the function with the same parameters sometimes yields</p> <pre><code>{31-10-10 20 nil, 31-10-10 10 nil, 31-10-10 21 nil, 30-10-10 21 nil, 31-10-10 00 nil, 31-10-10 11 nil, 31-10-10 22 nil, 30-10-10 22 nil, 31-10-10 01 nil, 31-10-10 12 nil, 30-10-10 23 nil, 31-10-10 02 nil, 31-10-10 13 nil, 31-10-10 03 nil, 31-10-10 14 nil, 31-10-10 04 nil, 31-10-10 15 nil, 31-10-10 05 nil, 31-10-10 16 nil, 31-10-10 06 nil, 31-10-10 17 nil, 31-10-10 07 nil, 31-10-10 18 nil, 31-10-10 08 nil, 31-10-10 19 nil, 31-10-10 09 nil} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload