Skip to content

Instantly share code, notes, and snippets.

@ruandao
Created December 4, 2015 01:15
Show Gist options
  • Save ruandao/69a971b3ae5763e399eb to your computer and use it in GitHub Desktop.
Save ruandao/69a971b3ae5763e399eb to your computer and use it in GitHub Desktop.
2.78
;#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