gpt4 book ai didi

random - 一个 Common Lisp 程序错误

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

这是代码:

 (defun my-random (max &optional least)
(setf max (+ max 1))
(if (null least)
(random max)
(if (numberp least)
(if (numberp max)
(let ((x (random (- max least))))
(+ x least))
(format t "~%在my-random函数中发现错误: 第一个输入值不是一个数字!~%"))
(format t "~%在my-random函数中发现错误: 第二个输入值不是一个数字!~%"))))

;我的随机数 100 1

(defun prozentual (probability command)
(if (numberp probability)
(if (listp command)
(if (> 101 probability)
(if (> probability (my-random 101 1))
command)
(format t "~%在prozentual函数中发现错误: 概率不得多于100!~%))
(format t "~%在prozentual函数中发现错误: 第二个参数不是一个命令!~%))
(format t "~%在prozentual函数中发现错误: 第一个参数不是一个数字!~%)))

;prozentual 100 (格式 t "as")

This is the Clozure Common Lisp Version 1.6 runs on the results:
? (load "mika.cl")
> Error: Reader error: Illegal symbol syntax.
> While executing: CCL::%PARSE-TOKEN, in process listener(1).
> Type :POP to abort, :R for a list of available restarts.
> Type :? for other options.
1 > (my-random 101 1)
61
1 > (my-random 101 100)
100
1 > (my-random 101 100)
100
1 > (my-random 101 100)
100
1 > (my-random 101 100)
100

现在不能使用“prozentual”函数..

最佳答案

您在 format 字符串末尾缺少双引号。

(defun prozentual (probability command)
(if (numberp probability)
(if (listp command)
(if (> 101 probability)
(if (> probability (my-random 101 1))
command)
(format t "~%在prozentual函数中发现错误: 概率不得多于100!~%"))
(format t "~%在prozentual函数中发现错误: 第二个参数不是一个命令!~%"))
(format t "~%在prozentual函数中发现错误: 第一个参数不是一个数字!~%")))

关于random - 一个 Common Lisp 程序错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18527997/

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