【SICP练习】82 练习2.54

来源:互联网 发布:久其软件 编辑:程序博客网 时间:2024/05/21 19:31

这些关于Scheme的基本知识在【Scheme归纳】系列博文总都有介绍。

(define (equal? x y)     (cond ((and (symbol? x) (symbol? y))               (symbol-equal? x y))            ((and (list? x) (list? y))             (list-equal? x y))            (else              (error “Error: You just input wrong type.”))(define (symbol-equal? x y)(eq? x y))(define (list-equal? x y)(cond ((and (null? x) (null? y))        #t)       ((or (null? x) (null? y))        #f)       ((equal? (car x) (car y))        (equal? (cdr x) (cdr y)))       (else #f)))

在倒数第二行中运用了递归。



感谢访问,希望对您有所帮助。 欢迎关注或收藏、评论或点赞。


为使本文得到斧正和提问,转载请注明出处:
http://blog.csdn.net/nomasp


5 0