2

This is the code:

 (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函数中发现错误: 第二个输入值不是一个数字!~%"))))

;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 (format 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

Now "prozentual" function can not be used ..

4
  • 1
    What is your question about the code? Commented Aug 30, 2013 at 8:11
  • Why the procedure to be wrong? Commented Aug 30, 2013 at 8:31
  • Sorry..I do not know the error information is described to me what Commented Aug 30, 2013 at 8:32
  • 4
    You're missing the ending doublequotes " on the format lines in prozentual. Commented Aug 30, 2013 at 8:36

1 Answer 1

9

YOu're missing the doublequotes at the end of the format strings.

(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函数中发现错误: 第一个参数不是一个数字!~%")))
Sign up to request clarification or add additional context in comments.

1 Comment

@46897asd I would recommend an editor with a decent lisp mode as the syntax highlighting in your editor should make it very clear when a double-quote like that is missing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.