<div>Thank you for the help. I just found expression in between define does not always cause this error. For example:</div>
<div> </div>
<div>(define (test x)<br> (add1 x)<br> (define (tst x)<br> (cond<br> [(= x 1) (add1 x)]<br> [else<br> (+ x 2)]))<br> (add1 x)<br> )</div>
<div><br>The problem is that it only executes the last expression. But in <a href="http://pre.racket-lang.org/docs/html/guide/syntax-overview.html">http://pre.racket-lang.org/docs/html/guide/syntax-overview.html</a></div>
<div> </div>
<div>it showed a code</div>
<div> </div>
<div>
<table class="RktBlk" cellspacing="0">
<tbody>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink" href="http://pre.racket-lang.org/docs/html/reference/define.html#(form._((lib._racket/private/base..rkt)._define))">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">bake</span><span class="hspace"> </span><span class="RktSym">flavor</span><span class="RktPn">)</span></td>
</tr>
<tr>
<td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktValLink" href="http://pre.racket-lang.org/docs/html/reference/Writing.html#(def._((quote._~23~25kernel)._printf))">printf</a></span><span class="hspace"> </span><span class="RktVal">"pre-heating oven...\n"</span><span class="RktPn">)</span></td>
</tr>
<tr>
<td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktValLink" href="http://pre.racket-lang.org/docs/html/reference/strings.html#(def._((quote._~23~25kernel)._string-append))">string-append</a></span><span class="hspace"> </span><span class="RktSym">flavor</span><span class="hspace"> </span><span class="RktVal">" pie"</span><span class="RktPn">)</span><span class="RktPn">)</span></td>
</tr></tbody></table></div>
<div> </div>
<div>Why can it execute two expressions there? </div>
<div> </div>
<div>In my question</div>
<div>(define (p x)<br> (+ x 10)<br> (* x 10)<br> )<br></div>
<div>It seems it only executes (* x 10)<br></div>
<div> </div>
<div><br></div>
<div class="gmail_quote">On Wed, Jun 1, 2011 at 3:43 PM, Joshua Ewulo <span dir="ltr"><<a href="mailto:jewulo@gmail.com">jewulo@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">try this instead
<div><br>
<div>(define (test x)</div>
<div> (define (add1 x) (+ x 1))</div>
<div class="im">
<div> (define (tst x)</div>
<div> (cond</div>
<div> [(= x 1) (add1 x)]</div></div>
<div> ......)))])</div>
<div> (add1 x))</div>
<div><br></div>
<div>I think all your define's are supposed to come before any function applications.<br><br>
<div class="gmail_quote">
<div>
<div></div>
<div class="h5">On 1 June 2011 23:24, Yingjian Ma <span dir="ltr"><<a href="mailto:yingjian.ma1955@gmail.com" target="_blank">yingjian.ma1955@gmail.com</a>></span> wrote:<br></div></div>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>
<div></div>
<div class="h5">
<div>1 I wrote the following code</div>
<div> </div>
<div>(define (test x)<br> (add1 x)<br> (define (tst x)<br> (cond<br> [(= x 1) (add1 x)]<br> else<br> (+ x 2))))<br> </div>
<div>and got error msg as</div>
<div> </div>
<div>begin (possibly implicit): no expression after a sequence of internal definitions in: ((add1 x) (define (tst x) (cond ((= x 1) (add1 x)) else (+ x 2))))</div>
<div> </div>
<div>What is wrong?</div>
<div> </div>
<div>The next two questions were posted a few minutes ago but I was not sure if they reached the website. I am putting them here</div>
<div> </div>
<div>2 I wrote<br> <br>(define (p x)<br> (+ x 10)<br> (* x 10)<br> )<br> <br>The result of (p 4) is 40. How can I display 14 and 40?<br> <br>3 How can I compare two letters in Ascii order? For example, when input are "x" and "y", the program will tell x is before y.<br>
<br>Thanks a lot.</div><br></div></div>_________________________________________________<br> For list-related administrative tasks:<br> <a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
</blockquote></div><br></div></div></blockquote></div><br>