• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Trying to understand some SCHEME

Alphathree33

Platinum Member
(define (respond s1)
(cond
[(not (symbol=? (square-val s1) 'blank)) "Invalid move"]
[else
(begin
(set-square-val! s1 turn))]))


What would be a psuedo-code equivalent that would help me understand what's going on here? (I haven't really done much scheme.)

My take:

function respond(s1)
{
if( ! square-val(s1) == "blank" ) return "Invalid Move"
else
{
set-squal-val!(s1, turn);
}
}

The most confusing expression for me is this: (symbol=? (square-val s1) 'blank))

Can someone parse that out in english for me?
 
Last edited by a moderator:
symbol=? isn't standard Scheme. You are probably using PLTScheme/Racket, which appears to define symbol=? as a synonym for the standard equal?.

In short, your pseudocode is correct. Just don't confuse the symbol 'blank with the string "blank". Assuming you are coming from a C or Java background, you can think of all the symbols in your Scheme code as labels of a single enum called symbol.
 
Back
Top