[racket] cond else and

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Wed Dec 12 05:42:50 EST 2012

2012/12/12 Frank Weytjens <fweytjens.android at gmail.com>:
> For example:
>
> (define (draw-shapes a-posn a-lon)
>   (cond
>     [(empty? a-lon) true]
>     [else (and (draw-circle a-posn (first a-lon))
>                (draw-shapes a-posn (rest a-lon)))]))
>
> Why is there an AND needed  in the else clause?
> ELSE is normaly used for all other cases, so you don't need to test anymore.
> In fact there is nothing tested in this line,  it is just used to be
> able to execute two expressions?
> Isn't there an other solution for this?
> That 's my point of view, I probably make a mistake, but I can't
> figure out which one.

In the teaching languages only one expression is allowed after the else.
If I remember correctly the Beginner languages does not include  begin
so and is used instead.

In "real" Racket and is not needed.

-- 
Jens Axel Søgaard


Posted on the users mailing list.