Scheme 检查expect函数
如上所述,它只是在列表的末尾添加一个X。您将如何为此编写一个简单的check expect函数?我将测试明显的情况,例如:Scheme 检查expect函数,scheme,racket,Scheme,Racket,如上所述,它只是在列表的末尾添加一个X。您将如何为此编写一个简单的check expect函数?我将测试明显的情况,例如: 如果我们将一个元素添加到一个空列表中会发生什么 如果我们将一个元素添加到一个包含一个元素的列表中,会发生什么 如果我们将一个元素添加到包含两个元素的列表中,会发生什么 等等。例如,第一个测试如下所示: ;; snoc : X [Listof Any] -> [Listof Any] ;; Adds the X to the end of the list (defin
;; 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)))]))
(check-expect (snoc 1 '()) '(1))