[plt-scheme] Combining digits to form numbers

From: aditya shukla (adityashukla1983 at gmail.com)
Date: Tue Feb 17 16:47:16 EST 2009

I removed the bugs from the cond condition .

(define check-guess3 (lambda(lsb csb msb target)
                       (cond
                         [(< (guess lsb csb msb) target) 'Toosmall]
                         [(= (guess lsb csb msb) target) 'Perfect]
                         [else 'Toolarge])))
(define guess (lambda (lsb csb msb)
                (+(* msb 100)(* csb 10) (* lsb 1))))


For removing the function call twice with the same argument i can i call it
before cond and store the return value in a variable .can it be done like
this

(define check-guess3 (lambda(lsb csb msb target)
                         define guess-n (guess lsb csb msb)
                          (cond
                           [(< guess-n target) 'Toosmall]
                           [(= guess-n target) 'Perfect]
                           [else 'Toolarge])))
(define guess (lambda (lsb csb msb)
                (+(* msb 100)(* csb 10) (* lsb 1))))


After doing this i get the error

lambda: expected only one expression for the function body, but found at
least one extra part

How can i fix this error?


Aditya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090217/f825f93c/attachment.html>

Posted on the users mailing list.