[racket] Printing multiple stmts in cond
Ok. Here's what I am trying to do.
I am parsing incoming racket code and generating back racket code.
In my case, I have an incoming function which takes 4 arguments and I need
to generate a function which takes in 5 args when a condition satisfies, if
not then the original 4 args .
Something like,
Input-->
(f x1 x2 x3 x4)
Output-->
(FF x1 x2 xNEW x3 x4)
--------------------------------------------------
(define (parse-func exp)
(cond
............
[(f? exp)
`(FF
,x1
,x2
,(if (condition?)
xNEW)
,x3
,x4)]
(The above is just pseudo-code) As shown above, when the if condition fails
I just want 4 args. But a default #<void> is passed instead when used with
cond.
I am new to racket and functional programing in general, so I am not able to
express my problem very accurately :(
Hope the above example is clear enough to explain what I am doing.
On Sat, Apr 30, 2011 at 7:00 AM, Neil Van Dyke <neil at neilvandyke.org> wrote:
> nikhil wrote at 04/30/2011 02:52 AM:
>
> 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.
>>
>
> An expression always produces at least one value, even if the value is the
> void value. (Usually, a REPL will hide a returned void value from you, but
> a void value is still being returned, which can be confusing.)
>
> If you can show *why* you don't want to produce *any* value, then people
> can show you different ways to write that code.
>
> --
> http://www.neilvandyke.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110430/243a8c70/attachment.html>