所以我对 acl2 和 lisp 还比较陌生,我不知道在 lisp 中这样做的方法。我怎样才能实现我的评论?(缺点...)我一直在思考迭代器,但有人告诉我 ACL2 只使用递归
(defun keep-at-most-n-bits (l n)
;cons a (up to n)
)
;;;unit tests.
(check-expect (keep-at-most-n-bits '(1 0 1 1) 3) '(1 0 1))
(check-expect (keep-at-most-n-bits '(1 0 1 1) 2) '(1 0))
(check-expect (keep-at-most-n-bits '(1 0 1 1) 8) '(1 0 1 1))