[racket] Cube

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

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

-------------- 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/e3668f0b/attachment.p7s>

Posted on the users mailing list.