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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:53:28+00:00 2026-06-18T09:53:28+00:00

The following procedure random-choice contains a procedure called choice: (define (random-choice strategy-1 strategy-2) (choice

  • 0

The following procedure random-choice contains a procedure called choice:

(define (random-choice strategy-1 strategy-2) 
 (choice strategy-1
 strategy-2
 (lambda (ship-state) (= (random 2) 0))))

How do I create the procedure choice that chooses the two strategies at random?
Also can you explain how lambda can be passed as an argument from procedure to procedure?

  • 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-18T09:53:29+00:00Added an answer on June 18, 2026 at 9:53 am

    Here’s an example of how you would choose a value at random, between two possible values:

    (define (choice s1 s2)
      (if (zero? (random 2)) s1 s2))
    

    The procedure returns the randomly chosen value, it’s up to you how to use it. And a lambda can be passed as an argument as any other value, there isn’t anything different about it. For example:

    ((choice (lambda (x) (first x))
             (lambda (x) (last  x)))
     '(1 2 3 4 5))
    

    The above will select randomly between a strategy for picking either the first or the last element in a list, and then it applies the selection to a list. Run it several times, you’ll see that sometimes 1 is returned, and sometimes 5 is returned.

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

Sidebar

Related Questions

I have a modal dialog that is created with the following: procedure TFormCompose.createParams(var Params:
I have the following stored procedure that I have to get data from: EXECUTE
I have following stored procedure: CREATE PROCEDURE testProc(IN p_idProject INTEGER) BEGIN DECLARE nowTime DATETIME;
I use the following mysql procedure, DROP PROCEDURE IF EXISTS `allied`.`GetRegistrationData`$$ CREATE DEFINER=`allied`@`%` PROCEDURE
I Defined the following procedure which compiles correctly. http://pastebin.com/pBHFctHq When i call that procedure
I have following stored procedure CREATE FUNCTION runMortalityModel(a_user_id integer) RETURNS integer AS $$ DECLARE
I have written the following procedure to create a series of 20 databases. But
I have the following procedure: CREATE PROCEDURE foo () SELECT * FROM fooBar INTO
How do I alter the following procedure in such a way that if insert
So the problem i am having is that if i execute the following procedure

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.