Skip to content

Commit

Permalink
Merge pull request #935 from burenkov-anton/tests-3.76
Browse files Browse the repository at this point in the history
Add tests for 3.76
  • Loading branch information
fey committed Jun 21, 2021
2 parents 8d08b0f + 6d9ad77 commit bb643c7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions resources/views/exercise/solution_stub/3_76.blade.php
@@ -0,0 +1,24 @@
#lang sicp
(#%require rackunit)


;;; BEGIN
{!! $solution !!}
;;; END

(define (stream-car stream) (car stream))

(define (stream-cdr stream) (force (cdr stream)))

(define sense-data (cons-stream 1
(cons-stream 2 (cons-stream 1.5 (cons-stream 1 (cons-stream 0.5
(cons-stream -0.1 (cons-stream -2 (cons-stream -3 (cons-stream -2
(cons-stream -0.5 (cons-stream 0.2 (cons-stream 3 4)))))))))))))


(define s (smooth sense-data))

(check-equal? (stream-car s) 3/2)
(check-equal? (stream-car (stream-cdr s)) 1.75)
(check-equal? (stream-car (stream-cdr (stream-cdr s))) 1.25)
(check-equal? (stream-car (stream-cdr (stream-cdr (stream-cdr s)))) 0.75)

0 comments on commit bb643c7

Please sign in to comment.