On Sat, Jun 23, 2012 at 12:45 PM, Roelof Wobben <span dir="ltr"><<a href="mailto:r.wobben@home.nl" target="_blank">r.wobben@home.nl</a>></span> wrote:<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>I have another "problem" I try to solve
in my head.<br>
<br>
Suppose I want to change one word in a sentence depening if a
comparision is true or false.<br>
<br>
I could do this in pseudo code.<br>
<br>
if comparision is true then print "it's true" else print "it's
not true"<br>
<br>
It works but I type two time's "it's true".<br>
<br>
Can this be done so I have to type only one time the sentence and
depeding on true or false the word not is used. <br><div>
<br>
Roelof<br>
<br></div></div></div></blockquote><div><br>I'm sure those with a deeper understanding of Racket than I could suggest something a little more elegant, but here's what I immediately came up with:<br><br>#lang racket<br>
<br>(define (print-statement some-cond)<br> (printf "~a~a~a~n" <br> "it's" <br>
(if some-cond <br> " " <br> " not ") <br> "true"))<br><br>(print-statement #f)<br>(print-statement #t)<br><br></div>
</div>