File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change
1
+ (import (rnrs)
2
+ (base)
3
+ (init)
4
+ (generic-arithmetic))
5
+
6
+ (init)
7
+ (display (make-scheme-number 3 ))(newline)
8
+ (display (add (make-scheme-number 3 )
9
+ (make-scheme-number 4 )))(newline)
Original file line number Diff line number Diff line change 10
10
(define get (operation-table 'lookup-proc ))
11
11
(define put (operation-table 'insert-proc! ))
12
12
(define (attach-tag type-tag contents )
13
- (cons type-tag contents))
13
+ (if (number? contents)
14
+ contents
15
+ (cons type-tag contents)))
14
16
(define (type-tag datum )
15
- (if ( pair ? datum)
16
- ( car datum)
17
- ( error 'type-tag " Bad tagged datum" datum)))
17
+ (cond (( number ? datum) 'scheme-number )
18
+ (( pair? datum) ( car datum) )
19
+ ( else ( error 'type-tag " Bad tagged datum" datum) )))
18
20
(define (contents datum )
19
- (if ( pair? datum)
20
- ( cdr datum)
21
- ( error 'contents " Bad tagged datum" datum)))
21
+ (cond (( number? datum) datum)
22
+ (( pair? datum) ( cdr datum) )
23
+ ( else ( error 'contents " Bad tagged datum" datum) )))
22
24
(define (square x )
23
25
(* x x))
24
26
(define (apply-generic op . args )
You can’t perform that action at this time.
0 commit comments