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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:55:25+00:00 2026-06-18T05:55:25+00:00

How do I generate random in Scheme? Is there a special form or would

  • 0

How do I generate random in Scheme? Is there a special form or would I have to create a procedure? And if so, how do I do that? (I’m trying to create a procedure called random-choice that inputs two strategies and returns one at random.)

  • 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-18T05:55:26+00:00Added an answer on June 18, 2026 at 5:55 am

    The procedure is called, surprisingly enough, random – although the exact syntax might be different depending on the Scheme interpreter in use (read the documentation!), but the general idea is as follows:

    (random)
    => 0.9113789707345018
    

    For returning one of two possible values, this will do the trick in Racket:

    (define (random-choice a b)
      (if (zero? (random 2)) a b))
    

    Notice that the 2 argument passed to random forces it to randomly return one of two possible values: 0 or 1. So if (random 2) evaluates to 0 then a is returned, otherwise b is returned.

    (random-choice 4 2)
    => 4
    (random-choice 4 2)
    => 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to generate random numbers manually. I know that every language have the
I have legacy C++ code that I wrote to generate uniform random numbers and
Trying to generate random digits with SecureRandom class of rails. Can we create a
Say I have a scheme that derives a key from N different inputs. Each
I want to generate random colours which can be attractive in pie charts.I have
I am trying to generate random numbers (integers) in Go, to no avail. I
I am trying to generate random DateTime instances using the DateTime Constructor (Int64) as
i have to generate random numbers for 3 different cases. i. 1 dice ii.
I am trying to generate random data for my sql server database. Ive created
How do I generate random chars and integers within a method so that 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.