我正在编写一个应该接受两个值的函数。第一个值应该根据输入的值创建最多五个数字的列表。第二个值应该获取列表并根据输入的数字将其旋转 n
次。
程序交互示例。
> (my_rotate_n 1,2)
> (3 4 5 1 2)
这是我目前拥有的功能。
(defun my_rotate_n (y) (x)
(append (loop for i from (+ 1 y) to (+ 4 y) collect i)
(> x 0) (my_rotate_n (rotate-right y)(- x 1)))(list y))
当我测试函数的输出时出现错误:comma is illegal outside of backquotes
有什么建议吗?
最佳答案
Comma :
The comma is part of the backquote syntax; see Section 2.4.6 (Backquote). Comma is invalid if used other than inside the body of a backquote expression as described above.
要分隔标记,请使用 Whitespace Characters .
IOW,而不是 (my_rotate_n 1,2)
你应该写 (my_rotate_n 1 2)
。
(这不会让你的 my_rotate_n
工作,当然,只是避免那个特定的错误。你应该花一些时间研究 Lisp 语法。)
关于list - 逗号在反引号之外是非法的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42180848/