Something is wrong with the way I wrote the gen-sim-map function. It stops after one account number, and the last number in the vector. I am wondering what I am doing wrong. I could solve the problem by applying repeat to the function, but that seems wrong to me.
Here is the data and the call; the function defs are below that.
(def acct-nums (gen-acct-nums 5))
#'ba1-app/acct-nums
ba1-app=> acct-nums
[10000 10001 10002 10003 10004 10005]
ba1-app=> (gen-sim-map acct-nums)
{10005 [\W 160.12]}
(defn random-trans
[]
(nth avail-trans (.nextInt random (count avail-trans))))
(defn random-amount
[]
(float (/ (.nextInt random (count (range 1 10000))) 25 )))
; Generate an account number. The range is arbitrary to make it look a real bank account #.
(defn gen-acct-nums [range-end-idx]
(vec (range 10000 (+ 10000 range-end-idx 1))))
(defn gen-sim-map [acct-nums]
(reduce
(fn [sim-map one-acct-num]
(let [trans (random-trans )
amt (random-amount )]
{ one-acct-num (vector trans amt) } ))
{}
acct-nums))
I suspect your problem is that you’re not changing the accumulator. I’d expect to see something like
or similar.