gpt4 book ai didi

lisp - 报告 LISP 中的错误

转载 作者:太空宇宙 更新时间:2023-11-03 18:55:41 25 4
gpt4 key购买 nike

我有这个函数可以把一个数字转换成某个基数,如果我引入的基数大于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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com