Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6959817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:19:20+00:00 2026-05-27T15:19:20+00:00

Something is wrong with the way I wrote the gen-sim-map function. It stops after

  • 0

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))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:19:21+00:00Added an answer on May 27, 2026 at 3:19 pm

    I suspect your problem is that you’re not changing the accumulator. I’d expect to see something like

    (defn gen-sim-map [acct-nums]
        (reduce
            (fn [sim-map one-acct-num]
                (let [trans (random-trans )
                     amt   (random-amount )]
                    (assoc sim-map one-acct-num (vector trans amt)) )) ; <---
            {}
            acct-nums))
    

    or similar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Unless I am doing something wrong, the way I am supposed to use ConfigurationSection,
Whichever way I do it, it seems something goes wrong when using the conditional
Is something wrong in :g-2-g/3/ or is the recursion in the global just missing?
Am I doing something wrong or is it not possible to specify a generic
There's something wrong with my code or I'm just not understanding this fully. I
I must be doing something wrong. I can't seem to execute my CustomValidator's ServerValidate
Am I doing something wrong is this a known issue with the ASP.NET MVC
I may be doing something wrong, but I haven't been able to find a
I must be doing something wrong here (because really, what are the chances of
Maybe I'm doing something wrong but I have a textarea where I've specified textAlign

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.