[racket] Printing multiple stmts in cond

From: Richard Cleis (rcleis at mac.com)
Date: Sat Apr 30 03:21:43 EDT 2011

On Apr 30, 2011, at 12:52 AM, nikhil wrote:

> 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 ...)

For conditionals with only one clause, use (when ... ...) or (unless ... ...)

> 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 ? 
> 

> 

What does it mean, to return nothing? 'if' will return the results of one of it's two clauses. However, a when statement will either return the result of it's only clause or something that represents nothing: void. A program can check for the result of void like any other value.


rac



Posted on the users mailing list.