【发布时间】:2014-09-19 18:50:09
【问题描述】:
我正在尝试编写一个函数,该函数将在数字列表的末尾添加一个新数字,但我似乎无法追踪并纠正我的语法错误。有人可以帮助我吗?谢谢!
(define (add the-list element)
(cond
((empty? the-list) (list element)
(else (cons (first the-list) cons (add (rest the-list) element))))))
(check-expect (four (list 2 5 4) 1) (list 2 5 4 1)) ; four adds num at the end of lon
【问题讨论】:
-
使用
add而不是four调用check-expect。
标签: list scheme element racket