[racket] Cube

From: John Clements (clements at brinckerhoff.org)
Date: Thu Sep 13 13:37:41 EDT 2012

On Sep 13, 2012, at 10:28 AM, Ashley Fowler wrote:

> 
> 
> ________________________________________
> From: John Clements [clements at brinckerhoff.org]
> Sent: Thursday, September 13, 2012 1:26 PM
> To: Ashley Fowler
> Cc: users at racket-lang.org
> Subject: Re: [racket] Cube
> 
> On Sep 13, 2012, at 10:22 AM, Ashley Fowler wrote:
> 
>> I have to write a procedure (cube-two X Y) that takes two numeric arguments
>> and returns a list of their cubes.
>> 
>> So far I have...
>> 
>> (define cube(lambda(x)(* x x x)))...which takes ONE numeric arguments...example below...
>> 
>> (cube 3) ==> ( 27)
>> 
>> 
>> How could I make it to take two numeric arguments?
>> 
>> For instance...
>> 
>> (cube-two 1 4)  ==> (1  64)
>> (cube-two 2 5)  ==> (8  125)
> 
> Well, it sounds like you've already done a big chunk of the work, by implementing 'cube'. Your best bet here is to *use* cube in order to define your cube-two function.
> 
> Are you using the HtDP textbook?  This would be a great time to write down a purpose statement and header.
> 
> John
> 
> 
> No I don't have a textbook. I just need suggestions on how to start cube 2

You might want to check out How To Design Programs: it's a textbook written by the developers of Racket, and you can read it free online, at 

http://www.htdp.org/2003-09-26/Book/

It has a *lot* of help with the question: "Help! How do I get started?"

John Clements

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4800 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20120913/8b103b71/attachment-0001.p7s>

Posted on the users mailing list.