Created
December 4, 2015 01:15
-
-
Save ruandao/69a971b3ae5763e399eb to your computer and use it in GitHub Desktop.
2.78
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;#lang planet neil/sicp | |
#lang racket | |
(require (planet soegaard/sicp:2:1/sicp)) | |
(define wave einstein) | |
;; type-tag, contents, attach-tag | |
(define (attach-tag tag contents) | |
(if (number? contents) | |
contents | |
(cons tag contents))) | |
(define (type-tag value) | |
(cond ((number? value) 'scheme-number) | |
((and (pair? value) | |
(symbol? (car value))) | |
(car value)) | |
(else (error "Unknown tag -- TYPE-TAG" value)))) | |
(define (contents value) | |
(cond ((number? value) value) | |
((and (pair? value) | |
(symbol? (car value))) | |
(cdr value)) | |
(else (error "Unknown contents -- CONTENTS" value)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment