[plt-scheme] Conditionals define ==> (when #t (define....

From: Grant Rettke (grettke at acm.org)
Date: Wed Apr 29 21:42:30 EDT 2009

On Wed, Apr 29, 2009 at 2:23 AM, Ziboon <ziboon at gmail.com> wrote:
> Why I can't do this :
>
> (if (= n 0)
>      (define lst (list 1 2 3))
>      (define lst2 (list 1 2 )) )

I've never tried such a thing. Reading the documentation, it explains
that the true and false body must be expressions. define is not an
expression. That is why you can't do it.

> How I can do this ?

Is that what you really want to do? How will you access the variables later on?

Do you really want (define lst (if (= n 0) (list 1 2 3) (list 1 2)))?


Posted on the users mailing list.