<br>Can someone expand on the syntax for symbols? I can develop the check-guess game simply without symbols but cannot with symbols.<br>Trying many versions of the symbol syntax but with no success.<br><br>This the example for symbols, but how can I test conditions with a symbol?<br>
<pre class="scheme">(<span class="keyword">define</span> (<span class="variable">reply</span> <span class="variable">s</span>)<br> (<span class="keyword">cond</span><br> [(<span class="builtin">symbol=?</span> <span class="variable">s</span> <span class="keyword">'</span><span class="variable">GoodMorning</span>) <span class="keyword">'</span><span class="variable">Hi</span>]<br>
[(<span class="builtin">symbol=?</span> <span class="variable">s</span> <span class="keyword">'</span><span class="variable">HowAreYou?</span>) <span class="keyword">'</span><span class="variable">Fine</span>]<br>
[(<span class="builtin">symbol=?</span> <span class="variable">s</span> <span class="keyword">'</span><span class="variable">GoodAfternoon</span>) <span class="keyword">'</span><span class="variable">INeedANap</span>]<br>
[(<span class="builtin">symbol=?</span> <span class="variable">s</span> <span class="keyword">'</span><span class="variable">GoodEvening</span>) <span class="keyword">'</span><span class="variable">BoyAmITired</span>]))<br>
</pre>;function check-guess<br>;given number evaluate to one of three answers<br>;number -> number -> string<br><br>tested without symbols and got it working so was trying to emulate this with symbols<br><br>(define (check-guess guess target)<br>
(cond<br> [(< guess target) "Too Small"]<br> [(= guess target) "Perfect"]<br> [(> guess target) "Too large"]<br> <br><br><br>;(define (check-guess guess target)<br>
; (cond<br>; [(symbol=? 'guess (< guess target) 'Too small)]<br>; [(symbol=? 'guess (= guess target) 'Perfect)]<br>; [(symbol=? 'guess (> guess target) 'Too Large)]))<br><br>;(define (check-guess guess target)<br>
; (cond<br>; [(symbol=? (< guess target) 'True 'Too Small)]<br>; [(symbol=? (= guess target) 'True 'Perfect)]<br>; [(symbol=? (> guess target) 'True 'Too Large)]))<br><br>;(define (check-guess guess target)<br>
; (= s( < guess target))<br>; (= s( = guess target))<br>; (= s( > guess target)) <br>; (cond<br>; [(symbol= s 'true 'Too Small)]<br>; [(symbol= s 'true 'Perfect)]<br>; [(symbol= s 'true 'Too Large)]))<br>
<br>;(define (check-guess guess target)<br>; [(symbol=? guess (< target guess) "Too small")]<br><br><br>