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

  • SEARCH
  • Home
  • 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 8829355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:48:58+00:00 2026-06-14T07:48:58+00:00

I cant figure out this scheme code please help. Compute-frequencies takes in two separate

  • 0

I cant figure out this scheme code please help. Compute-frequencies takes in two separate lists looking-for-list and pool-list. It is supposed to return a list that shows how many times everything in looking-for-list is in pool-list.
I know I am close it is just some little error most likely having to do with the recursive call after making it through pool-list.

(define (compute-frequencies looking-for-list pool-list) 
  (define (helper looking-for-list pool-list current-frequency frequency-list)  ; keeps track of finished list and iterates through both lists
    (if (null? looking-for-list) (reverse frequency-list)                       ; finding the number of times data in looking-for-list are in pool-list
    (if (null? pool-list)
        (helper (cdr looking-for-list) pool-list 0 (cons current-frequency frequency-list))
        (if (equal? (car looking-for-list) (car pool-list))
        (helper looking-for-list (cdr pool-list) (+ 1 current-frequency) frequency-list)
        (helper looking-for-list (cdr pool-list) current-frequency frequency-list)))))

 (helper looking-for-list pool-list 0 '() ))
  • 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-06-14T07:48:59+00:00Added an answer on June 14, 2026 at 7:48 am

    Alright reading your code it seems like your algorithm itself is perfectly fine. The problem is much simpler.

    Look at your code, once you’ve checked all the elements of pool-list for the first element in your looking-for-list you want to restore pool-list to its original state. To do this, you call helper with pool-list as pool-list. You almost certainly mean the one defined in the compute-frequency arguments but Scheme takes the one in helper‘s arguments since it shadow’s the one in compute-frequency. This means that after the first iteration, pool-list is just '() so the frequency of everything else is 0.

    To solve this, do some renaming. In the future, try to remember that Scheme variables can and will shadow ones in a larger scope. And also, try using cond instead of nested if statements. Much more readable in Scheme (it’s how I found this problem)

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

Sidebar

Related Questions

I am getting segmentation fault in this code but i cant figure out why.
I want to do something but cant figure out how to do this (i
This seems in my head like it should work but I cant figure out
I cant really figure out whats wrong with this. I used to write the
hey guys having this really simple problem but cant seem to figure out have
I can't figure out what this grey text indicates or if it's a glitch
I can't figure out why this is. I have a connect method that works
I can't figure out why this list is not displaying properly in IE7. The
I can't figure out why this UIView doesn't display correctly when the method is
I can't figure out why this won't work, I've tried it 100 ways. The

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.