[racket] Symbol Syntax

From: Sayth Renshaw (flebber.crue at gmail.com)
Date: Wed Jan 5 07:18:37 EST 2011

Can someone expand on the syntax for symbols? I can develop the check-guess
game simply without symbols but cannot with symbols.
Trying many versions of the symbol syntax but with no success.

This the example for symbols, but how can I test conditions with a symbol?

(define (reply s)
  (cond
    [(symbol=? s 'GoodMorning) 'Hi]
    [(symbol=? s 'HowAreYou?) 'Fine]
    [(symbol=? s 'GoodAfternoon) 'INeedANap]
    [(symbol=? s 'GoodEvening) 'BoyAmITired]))

;function check-guess
;given number evaluate to one of three answers
;number -> number -> string

tested without symbols and got it working so was trying to emulate this with
symbols

(define (check-guess guess target)
    (cond
      [(< guess target) "Too Small"]
      [(= guess target) "Perfect"]
      [(> guess target) "Too large"]



;(define (check-guess guess target)
;  (cond
;    [(symbol=? 'guess (< guess target) 'Too small)]
;    [(symbol=? 'guess (= guess target) 'Perfect)]
;    [(symbol=? 'guess (> guess target) 'Too Large)]))

;(define (check-guess guess target)
;  (cond
;    [(symbol=? (< guess target) 'True 'Too Small)]
;    [(symbol=? (= guess target) 'True 'Perfect)]
;    [(symbol=? (> guess target) 'True 'Too Large)]))

;(define (check-guess guess target)
;  (= s( < guess target))
;  (= s( = guess target))
;  (= s( > guess target))
;  (cond
;    [(symbol= s 'true 'Too Small)]
;    [(symbol= s 'true 'Perfect)]
;    [(symbol= s 'true 'Too Large)]))

;(define (check-guess guess target)
;  [(symbol=? guess (< target guess) "Too small")]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110105/7eed739d/attachment.html>

Posted on the users mailing list.