;; snoc : X [Listof Any] -> [Listof Any]
;; Adds the X to the end of the list
(define (snoc x l)
(cond [(empty? l) (cons x empty)]
[else (cons (first l)
(snoc x (rest l)))]))
如上所述,它只是在列表末尾添加一个 X。您将如何为此编写一个简单的检查期望函数?
I'd test the obvious cases, for example:
And so on. For example, the first test would look like this:
(check-expect (snoc 1 '()) '(1))