[racket] two question about DrRacket

From: Hendrik Boom (hendrik at topoi.pooq.com)
Date: Thu Jun 2 08:52:14 EDT 2011

On Wed, Jun 01, 2011 at 02:57:41PM -0700, Yingjian Ma wrote:
> Hi all,
> 
> 1  I wrote
> 
> (define (p x)
>   (+ x 10)
>   (* x 10)
>   )
> 
> The result of (p 4) is 40.  How can I display 14 and 40?

You could return a list instead of the individual numbers.  The way 
you've coded it, the 14 is computed, then discarded.  Then the 40 is 
computed and returned.

In LISP I'd code (list (+ x 10) (* x 10)).  I'm not quite sure if 'list' 
is still called 'list' in Scheme, though; a lot of the built-in function 
names have changed since the 60's, when I was heavily involved with 
Lisp. Look it up.

-- hendrik


Posted on the users mailing list.