-
Notifications
You must be signed in to change notification settings - Fork 3
/
pp03-double-error.rkt
45 lines (37 loc) · 935 Bytes
/
pp03-double-error.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#lang htdp/bsl
; PROBLEM:
;
; There may be more than one problem with this function design. Uncomment
; the function design below, and make the minimal changes required to
; resolve the error that occurs when you run it.
;
; ;; Number -> Number
; ;; doubles n
; (check-expect (double 0) 0)
; (check-expect (double 4) 8)
; (check-expect (double 3.3) (* 2 3.3))
; (check-expect (double -1) -2)
;
;
; #;
; (define (double n) 0) ; stub
;
; (define (double n)
; (* (2 n)))
;; Number -> Number
;; Produce the double of its input number.
(check-expect (double 0) 0)
(check-expect (double 4) 8)
(check-expect (double 3.3) (* 2 3.3))
(check-expect (double -1) (* 2 -1))
;(define (double n) 0) ; stub
#;
(define (double n) ;template
(... n))
(define (double n)
(* 2 n))
;; Things corrected:
;; - Better purpose description.
;; - Improve last check-expect "meaning".
;; - Add missing template.
;; - Fix body of function definition.