htdf 是 how to design functions 的缩写。
在介绍这章需要注意的知识点之前, 如果对视频没什么印象的朋友们, 辛苦你们
再看一次,毕竟经典是拿来重温的\\( ̄<  ̄)>
视频拉到4:13 开始播放就行, 4:13之前是在阐述htdf对于生活的意义.
[media]https://www.youtube.com/watch?v=AyFI91za4P0[/media]
**1.signature
2.purpose
3.check-expect
4.stub
5.function body**
htdf是这五个步骤,并且需要死记一下的,其实当mt前刷htdf题多了以后, 就
(@htdf double)
(@signature Number -> Number)
;; produces n times 2
(check-expect (double 0) (* 0 2))
(check-expect (double 1) (* 1 2))
(check-expect (double 3) (* 3 2))
;(define (double n) 0) ; this is the stub
(@template Number)
;(define (double n) ; this is the template
; (... n))
(define (double n)
(* n 2))