list - 逗号在反引号之外是非法的?

标签 list syntax lisp common-lisp backquote

我正在编写一个应该接受两个值的函数。第一个值应该根据输入的值创建最多五个数字的列表。第二个值应该获取列表并根据输入的数字将其旋转 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/

相关文章:

lisp - 查找普通 lisp 中的字符频率

emacs - 重新编译不会更正函数调用中的拼写错误

c - 如何实现延续?

java - 如何使用java对对象列表进行排序

c - 在 while 循环中与乘法一起使用的后递增

python - N 选择列表的 N/2 个子列表

scala - 在 Scala 中,每个 "setter"方法都需要一个 "getter"方法?

MySQL 语法 - IF/END IF

java - 如何将列表的元素添加到另一个列表?

java - 如何使用ArrayList动态添加多个学生数据?