[racket] Three questions related DrRacket

From: Yingjian Ma (yingjian.ma1955 at gmail.com)
Date: Wed Jun 1 19:22:01 EDT 2011

Thank you for the help.  I just found expression in between define does not
always cause this error.  For example:

(define (test x)
  (add1 x)
  (define (tst x)
  (cond
    [(= x 1) (add1 x)]
    [else
    (+ x 2)]))
  (add1 x)
  )

The problem is that it only executes the last expression.  But in
http://pre.racket-lang.org/docs/html/guide/syntax-overview.html

it showed a code

  (define<http://pre.racket-lang.org/docs/html/reference/define.html#(form._((lib._racket/private/base..rkt)._define))>
 (bake flavor)
(printf<http://pre.racket-lang.org/docs/html/reference/Writing.html#(def._((quote._~23~25kernel)._printf))>
 "pre-heating oven...\n")
(string-append<http://pre.racket-lang.org/docs/html/reference/strings.html#(def._((quote._~23~25kernel)._string-append))>
 flavor " pie"))

Why can it execute two expressions there?

In my question
(define (p x)
  (+ x 10)
  (* x 10)
  )
It seems it only executes (* x 10)


On Wed, Jun 1, 2011 at 3:43 PM, Joshua Ewulo <jewulo at gmail.com> wrote:

> try this instead
>
> (define (test x)
>    (define (add1 x) (+ x 1))
>     (define (tst x)
>        (cond
>              [(= x 1) (add1 x)]
>              ......)))])
>     (add1 x))
>
> I think all your define's are supposed to come before any function
> applications.
>
>   On 1 June 2011 23:24, Yingjian Ma <yingjian.ma1955 at gmail.com> wrote:
>
>>   1  I wrote the following code
>>
>> (define (test x)
>>   (add1 x)
>>   (define (tst x)
>>   (cond
>>     [(= x 1) (add1 x)]
>>     else
>>     (+ x 2))))
>>
>> and got error msg as
>>
>> 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))))
>>
>> What is wrong?
>>
>> 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
>>
>> 2  I wrote
>>
>> (define (p x)
>>   (+ x 10)
>>   (* x 10)
>>   )
>>
>> The result of (p 4) is 40.  How can I display 14 and 40?
>>
>> 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.
>>
>> Thanks a lot.
>>
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://lists.racket-lang.org/listinfo/users
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110601/1a65a257/attachment.html>

Posted on the users mailing list.