Remove display debugging and use racket/trace instead

This commit is contained in:
Oliver Payne 2022-03-27 22:11:47 +01:00
parent 8c12ac0e4c
commit 05c804bb79
1 changed files with 11 additions and 39 deletions

View File

@ -1,4 +1,5 @@
#lang sicp
(#%require racket/trace)
;;;from section 1.2.5, for Section 2.1.1
@ -128,19 +129,11 @@
(proc (get op type-tags))
(result
(if proc
(begin
(display "Applying ")
(display (list op args))
(newline)
(apply proc (map contents args)))
(apply proc (map contents args))
(if (> (length args) 1)
(let ((coerced-args (coerce-args args type-tags)))
(if (not (null? coerced-args))
(begin
(display "Applying with coerced args ")
(display (list op coerced-args))
(newline)
(apply apply-generic (cons op coerced-args)))
(apply apply-generic (cons op coerced-args))
(error "Can't coerce arguments to a common type"
(list op type-tags))))
(error "No matching operator for args" op args)))))
@ -151,16 +144,8 @@
(eq? op 'imag-part)
(eq? op 'angle)
(eq? op 'magnitude))))
(begin
(display "Drop ")
(display result)
(newline)
(drop result))
(begin
(display "Result ")
(display result)
(newline)
result))))
(drop result)
result)))
;; scheme-number is for reals only
(define (scheme-number? x)
@ -640,7 +625,6 @@
(make-term 0 0))))
(put 'rest-terms '(sparse)
(lambda (termlist)
(display termlist)
(if (pair? termlist)
(tag (cdr termlist))
(the-empty-termlist))))
@ -745,24 +729,12 @@
(define (drop x)
(and (type-tagged? x)
(let ((p (project x)))
(begin
(display "drop: ")
(display x)
(newline)
(cond ((null? p)
(display "drop: p Null ")
(newline)
x)
((equ? x (raise p))
(display "drop: x equal to raise p, dropping ")
(display p)
(newline)
(drop p))
(else
(display "drop: returning ")
(display x)
(newline)
x))))))
(cond ((null? p)
x)
((equ? x (raise p))
(drop p))
(else
x)))))
(install-scheme-number-package)
(install-integer-package)