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 9154577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:26:57+00:00 2026-06-17T12:26:57+00:00

I just started racket so excuse me if this is a dumb question. Can

  • 0

I just started racket so excuse me if this is a dumb question. Can someone tell me what exactly I am doing wrong? I am trying to find the value of:

(cond
  [(<= (string-length s) 5) 10]
  [(string=? s “hello”) 50]
  [(string=? (substring s 1 4) “ell”) 25]
  [else 130])

when when s is (i) "hello" and s is (ii) "hellos" .

I did one similar with numbers where all I had to do was define it with a number and had no problems. I don’t know what I am doing wrong here.

edit-

like for this one. Where they ask for the value of n when its 150000.
I simply define n as 150000I get “mb” as the value.

;;(define n 15000)

(cond
  [(<= n 1000) (number->string n)]
  [(<= n 5000) 
(string->symbol 
(string-append "num" (number->string n)))]
  [else (substring 
(string-append "number" (number->string n)) 2 4)])

i am trying to do the ame with the above. if this makes any sense.

  • 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-17T12:26:58+00:00Added an answer on June 17, 2026 at 12:26 pm

    Notice that strings must be surrounded by "" to work, in your code you’re using a similar but not-quite-right kind of double quotes. Try this instead:

    (define s "hello")
    
    (cond
      [(<= (string-length s) 5) 10]
      [(string=? s "hello") 50]
      [(string=? (substring s 1 4) "ell") 25]
      [else 130])
    

    Besides that, the code has no errors per-se, but it’s possible that the result obtained is not the one you expected because of the order in which the different conditions appear in the cond, try switching some, reorganizing them, etc.

    Bear in mind that the conditions are evaluated from top-to-bottom and the first condition that is true will be executed. For example, if the input is "hello", (<= (string-length s) 5) gets evaluated and executed before (string=? s "hello"), because the first condition is true, and the second condition is never reached and therefore never executed.

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

Sidebar

Related Questions

I'm just started learning scheme and can't quite understand why this function does not
Just started using App Engine's webapp framework, but I can't figure out what's wrong
Just started playing with ninject - and I can't get past this issue. Consider
Just started learning algorithms. So the exercise is to find if statement is always/sometimes
Just started learning about SQL, and doing very basic stuff using SQLPlus. I've literally
Just started using VBA and I'm trying to access all the data in a
Just started learning Haskell. I have an empty source file with this inside: pe
Just started testing Zoho Crm as a CRM solution for our company. Someone asked
Just started writing java / android and I am trying to use android.widget.VideoView. I
Just started a tutorial in SQL for beginners. I'm doing some exercises now and

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.