list - lisp 列表连接

标签 list lisp concatenation common-lisp

我如何编写一个函数,它有两个列表的参数并返回 连接两个列表,不使用追加。

I know how to get the head of the second list but I don't know how to put it in the first one and what should I do if the head of the list is also a list.

最佳答案

是否允许使用 LOOP 或 DO?

像这样的东西会起作用:

(defun my-concat (x y)
  (loop 
    for o in (reverse x)
    do (push o y)
    finally (return y)))

如果循环不是一个选项,您可能想使用递归。

关于list - lisp 列表连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15267665/

相关文章:

c - 在 Common Lisp 中为英特尔 x86-64 编写 Linux 内核模式调试器是否可行,以及使用哪个 Common Lisp 实现[s]?

java - 每4个字符将char放入java字符串中

python - 连接和重新排列文件的最有效方法

php - 如何用逗号分隔数组的值以供显示

python - 从用户那里获取输入并将其附加到列表后,如何在 python 中查看列表的内容?

python - 将二进制数转换为包含每个二进制数的数组

recursion - 检查二叉树是否为二叉搜索树的 Lisp 程序

lisp - Lisp 中余弦函数的泰勒级数

C 字符数组连接

python - 查找 : any one of the substrings (whichever first) stored in a list; in a bigger string in Python 的出现位置