<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">(if (condition? data)<div> (FF x1 x2 xNEW x3 x4)</div><div> (f x1 x2 x3 x4))</div><div><br></div><div>The result of one of them is returned.</div><div><br></div><div>rac<br><div><br></div><br><div><div>On Apr 30, 2011, at 1:16 AM, nikhil wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Ok. Here's what I am trying to do.</div><div><br></div><div>I am parsing incoming racket code and generating back racket code. </div><div><br></div><div>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 .</div>
<div><br></div><div>Something like,</div><div><br></div><div>Input--> </div><div>(f x1 x2 x3 x4)</div><div><br></div><div>Output--></div><div>(FF x1 x2 xNEW x3 x4)</div><div><br></div><div>--------------------------------------------------</div>
<div><br></div><div><div>(define (parse-func exp)</div><div> (cond</div></div><div>............</div><div><br></div><div><div> [(f? exp)</div><div> `(FF</div><div> ,x1</div><div> ,x2</div><div> ,(if (condition?)</div>
<div> xNEW)</div><div> </div><div> ,x3</div><div> ,x4)]</div></div><div><br></div><div>(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. </div>
<div><br></div><div>I am new to racket and functional programing in general, so I am not able to express my problem very accurately :(</div><div>Hope the above example is clear enough to explain what I am doing. </div><div>
<br></div><br><br><div class="gmail_quote">On Sat, Apr 30, 2011 at 7:00 AM, Neil Van Dyke <span dir="ltr"><<a href="mailto:neil@neilvandyke.org">neil@neilvandyke.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
nikhil wrote at 04/30/2011 02:52 AM:<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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.<br>
</blockquote>
<br></div>
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.)<br>
<br>
If you can show *why* you don't want to produce *any* value, then people can show you different ways to write that code.<br><font color="#888888">
<br>
-- <br>
<a href="http://www.neilvandyke.org/" target="_blank">http://www.neilvandyke.org/</a><br>
</font></blockquote></div><br>
_________________________________________________<br> For list-related administrative tasks:<br> <a href="http://lists.racket-lang.org/listinfo/users">http://lists.racket-lang.org/listinfo/users</a></blockquote></div><br></div></body></html>