[plt-scheme] Combining digits to form numbers

From: aditya shukla (adityashukla1983 at gmail.com)
Date: Mon Feb 16 14:59:03 EST 2009

I am trying to solve this exercise from htdp


*Exercise 5.1.3.*   Develop the function check-guess3. It implements a
larger portion of the number guessing game of exercise
the function
check-guess. Now the teachpack hands over the digits that the user guesses,
not the number that they form.

To simplify the problem a little bit, the game works with only three
numbers. Thus, check-guess3 consumes three digits and a number. The first
digit is the least significant, the third one is the most significant. The
number is called target and represents the randomly chosen number. Depending
on how guess, the number determined by the three digits, relates to target,
check-guess3 produces one of the following three answers: 'TooSmall, '
Perfect, or 'TooLarge.

The rest of the game is still implemented by *guess.ss*. To play the game
with check-guess3, evaluate

(guess-with-gui-3 check-guess3)

after the function has been thoroughly tested.

My solution is like this
contract for check-guess3

;; check-guess3 :: number * number * number  * number > symbol


(define check-3 (lambda(lsb csb msb number)....)


(define check-guess3 (lambda(lsb csb msb number)
                         [(< guess(lsb csb msb) number) 'Toosmall]
                         [(= guess(lsb csb msb) number) 'Perfect]
                         [else 'Toolarge])))

contract for guess

;;guess :: number * number *number -> number


(define guess (lambda(lsb csb msb)...)


(define guess (lambda(lsb csb msb)
        This is the part which i was not able to do , how can i combine lsb
, csb and msb so the number is of the form (msbcsblsb) .Is there any
function in scheme which can do this


Any help is appreciated.

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

Posted on the users mailing list.