Skip to content

Commit

Permalink
Convert exercise files to .scm
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Leimkuhler committed Mar 1, 2018
1 parent ba6f795 commit c8f564e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 19 deletions.
4 changes: 1 addition & 3 deletions 1/ex-all.rkt → 1/ex-all.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#lang racket

;; --------------------------------------------------
;; All functions are defined below. No executions take place when
;; run; use the REPL to test
Expand Down Expand Up @@ -569,4 +567,4 @@
((iterative-improve
(lambda (guess) (< (abs (- (f guess) guess)) tolerance))
f)
first-guess))
first-guess))
6 changes: 2 additions & 4 deletions 2/ex-1-32.rkt → 2/ex-1-32.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#lang racket

;; --------------------------------------------------
;; Common defines used among exercises
(define (gcd a b)
Expand Down Expand Up @@ -85,7 +83,7 @@
(define (dispatch m)
(cond ((= m 0) x)
((= m 1) y)
(else (error "Argument not 0 or 1 -- CONS" m))))
(else (display "Error: Argument not 0 or 1 -- CONS" m))))
dispatch)

(define (car-proc-dispatch z) (z 0))
Expand Down Expand Up @@ -169,7 +167,7 @@
;; 2.10
(define (div-interval x y)
(if (and (<= (lower-bound y) 0) (>= (upper-bound y) 0))
(error "Error: The denominator can not span 0")
(display "Error: The denominator can not span 0")
(mul-interval
x
(make-interval (/ 1.0 (upper-bound y))
Expand Down
2 changes: 0 additions & 2 deletions 2/ex-33-52.rkt → 2/ex-33-52.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#lang racket

;; Following along with reading
(define (accumulate op initial sequence)
(if (null? sequence)
Expand Down
4 changes: 1 addition & 3 deletions 2/ex-53-66.rkt → 2/ex-53-66.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#lang racket

;; 2.53
;; Notepad exercises

Expand Down Expand Up @@ -71,7 +69,7 @@
(make-sum (exponent exp) -1)))
(deriv (base exp) var)))
(else
(error "unknown expression type -- DERIV" exp))))
(display "Error: unknown expression type -- DERIV" exp))))

;; 2.57
(define (augend-prefix a)
Expand Down
2 changes: 0 additions & 2 deletions 2/ex-67-86.rkt → 2/ex-67-86.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#lang racket

;; Following along with reading
(define (make-leaf symbol weight) (list 'leaf symbol weight))
(define (leaf? object) (eq? (car object) 'leaf))
Expand Down
8 changes: 3 additions & 5 deletions 2/ex-87-end.rkt → 2/ex-87-end.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#lang racket

(define (install-polynomial-dense-package)
;; term-list implementation independent internal procedures
(define (variable p) (car p))
Expand All @@ -10,7 +8,7 @@
(define (empty-termlist) '())
(define (rest-terms term-list) (cdr terml-list))
(define (empty-termlist? term-list) (null? term-list))
p(define (make-term order coeff) (list order coeff))
(define (make-term order coeff) (list order coeff))
(define (order term) (car term))
(define (coef term) (cadr term))

Expand Down Expand Up @@ -131,7 +129,7 @@
(define (empty-termlist) '())
(define (rest-terms term-list) (cdr terml-list))
(define (empty-termlist? term-list) (null? term-list))
p(define (make-term order coeff) (list order coeff))
(define (make-term order coeff) (list order coeff))
(define (order term) (car term))
(define (coef term) (cadr term))

Expand Down Expand Up @@ -248,7 +246,7 @@
(define (sparse-poly? p)
;; If half the length of terms is less than the length of terms without
;; zeroes, then sparse poly is optimal
(if (< (/ (length p) 2) (length (filter (not zero?) p)) 2))
(if (< (/ (length p) 2) (length (filter (not (zero? p)) 2)))
#t
#f))

Expand Down

0 comments on commit c8f564e

Please sign in to comment.