HTDP读书笔记(2)

HTDP学习到了section5 以前学TSL的时候一直没有接触过Scheme的Symbolic的实际操作,刚接触觉得很新鲜而且到现在为止HTDP里的练习都还很简单,现在对Scheme写GUI很好奇,不知道什么时候才能学到,练习5.1.5虽然不难但是却被它折磨了半天,今天偶然间调试了下才发现and中少了几对括号这么低级的错误…………

(define (check-color t1 t2 g1 g2)
  (cond
    [(and (symbol=? t1 g1) (symbol=? t2 g2)) 'Perfect]
    [(or (and (symbol=? t1 g1) (not(symbol=? t2 g2)))
         (and (symbol=? t2 g2) (not(symbol=? t1 g1))))
     'OneColorAtCorrectPosition]
    [(or (and (symbol=? t1 g2) (not(symbol=? t2 g1)))
         (and (symbol=? t2 g1) (not(symbol=? t1 g2))))
     'OneColorOccurs]
    [else 'NothingCorrect]))

 

你可能感兴趣的:(Scheme,读书)