Common Lisp程序错误

468*_*asd 2 lisp random common-lisp

这是代码:

 (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???????: ????????????!~%"))))
Run Code Online (Sandbox Code Playgroud)

;我的随机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???????: ???????????!~%)))
Run Code Online (Sandbox Code Playgroud)

; prozentual 100(格式为"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
Run Code Online (Sandbox Code Playgroud)

现在"prozentual"功能无法使用..

Bar*_*mar 9

你错过了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???????: ???????????!~%")))
Run Code Online (Sandbox Code Playgroud)

  • @ 46897asd我会推荐一个具有不错的lisp模式的编辑器,因为编辑器中的语法突出显示应当在缺少这样的双引号时非常清楚. (4认同)