• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Anyone familiar with Scheme programming?

hans030390

Diamond Member
I'm in an intro to computer science class, and there's one problem I can't quite figure out. I have to create a procedure, "pick-one-at-random" that will select one of two given arguments randomly (with equal probibility).

Examples:

> (pick-one-at-random 1 -1)
1
> (pick-one-at-random #t #f)
#f
> (pick-one-at-random #t 64)
#t
> ((pick-one-at-random + -) 3 4)
7
> (pick-one-at-random
(pick-one-at-random 1 2)
(pick-one-at-random 3 4))
4

My professor said to "think of it as flipping a coin, and one coin only" and that we only need to use "if" once in our code.

Can anyone provide and help or hints?
 
I don't see how this answers or helps my problem. I give it two arguments, and it simply picks between one of them. Random picks a random number below the given argument.

I just learned that I need to have to "random"s in my code...one if...I suppose that helps a bit...any ideas?
 
Scheme is a very good OO language. EMBRACE IT!!!!

You will elarn concepts via Scheme more so than most other languages (Java included)
 
Originally posted by: IHateMyJob2004
Scheme is a very good OO language. EMBRACE IT!!!!

You will elarn concepts via Scheme more so than most other languages (Java included)

Scheme is a functional language...
 
Not entirely. Like most other languages, Scheme can be used to write purely functional programs, but that certainly isn't its only use. There is also support for OOP via add-ons.
 
Back
Top