[racket] Printing multiple stmts in cond

From: nikhil (nik.mis at gmail.com)
Date: Sat Apr 30 02:52:37 EDT 2011

What you guys suggest solves the problem of returning multiple values. Since
I havent provided any context, my original problem still exists. Sorry about
that.

This is what I was trying to do,

(if (condition?)
     (stmt1))

(if (condition?)
     (stmt2)
     (stmt3))

In the first if condition(stmt1), I have no else condition. Since this is
not allowed, I used (cond ...) which returns #<void> by default when there's
no else. This #<void> is being somehow copied to the returned list.

So I tried clubbing multiple return statements in cond stmt because I had no
else condition.

Basically, I dont want to execute an else stmt or return multiple values. I
just want to return "stmt1" if condition satisfies and dont do anything if
false. No returning #<void> or anything.

Am I making any sense ? if yes, is it possible ?



On Sat, Apr 30, 2011 at 6:28 AM, Richard Cleis <rcleis at mac.com> wrote:

> You can return more than one by forming a list, or by using something like
> (values val-1 val-2 ...)
>
> rac
>
> On Apr 29, 2011, at 11:45 PM, nikhil wrote:
>
> Hi,
>
> I am new to Racket so please bear with me. I am trying to print multiple
> expressions in "cond" statement as below.
>
> (let ((var `(make))
>
>         (exp '(1 2)))
>
>     (cond
>
>       [(number? 2) `(hi ,var)
>
>                               `(bye ,exp)]))
>
>
>
> But only the "bye" statement is returned/printed on the screen. The first
> "hi" is not evaluated at all. How do I return/print both ?
>
> Thanks
>
>
> Nik
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110430/1af18e85/attachment.html>

Posted on the users mailing list.