<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">(if (condition? data)<div>&nbsp;&nbsp; &nbsp;(FF&nbsp;x1&nbsp;x2&nbsp;xNEW&nbsp;x3&nbsp;x4)</div><div>&nbsp;&nbsp; &nbsp;(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.&nbsp;</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&nbsp;satisfies, if not then the original 4 args .</div>
<div><br></div><div>Something&nbsp;like,</div><div><br></div><div>Input--&gt;&nbsp;</div><div>(f x1 x2 x3 x4)</div><div><br></div><div>Output--&gt;</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>&nbsp;&nbsp; (cond</div></div><div>............</div><div><br></div><div><div>&nbsp;&nbsp; [(f? exp)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; `(FF</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ,x1</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ,x2</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ,(if (condition?)</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xNEW)</div><div>&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ,x3</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ,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 #&lt;void&gt; is passed instead when used with cond.&nbsp;</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.&nbsp;</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">&lt;<a href="mailto:neil@neilvandyke.org">neil@neilvandyke.org</a>&gt;</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 #&lt;void&gt; or anything.<br>
</blockquote>
<br></div>
An expression always produces at least one value, even if the value is the void value. &nbsp;(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> &nbsp;For list-related administrative tasks:<br> &nbsp;<a href="http://lists.racket-lang.org/listinfo/users">http://lists.racket-lang.org/listinfo/users</a></blockquote></div><br></div></body></html>