我有这个函数可以把一个数字转换成某个基数,如果我引入的基数大于9小于2但我不知道,我想报错。你能帮帮我吗?
(defun zecb (number base)
(write-to-string number :base base))
最佳答案
CL-USER 99 > (defun test (n)
(check-type n (integer 2 9))
n)
TEST
CL-USER 100 > (test 2)
2
CL-USER 101 > (test 9)
9
CL-USER 102 > (test 10)
Error: The value 10 of N is not of type (INTEGER 2 9).
关于lisp - 报告 LISP 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33843740/