【发布时间】:2013-04-30 01:25:50
【问题描述】:
我有以下常用的 lisp 函数:(aggregate line1 line2) 和 (queuer data result)。
queuer 应该将值 line1 和 line2 推入结果,如果它们的第一个字段不同,或者这 2 行的聚合如果它们的第一个字段相等。
我不知道为什么它没有改变我的结果列表。
注意:我正在使用(push (pop data) result) 初始化结果列表,以便在其中包含第一个元素。这 2 个列表是 1 深度嵌套列表 (("1" "text") ("2" "text") (...))。
(defun aggregate (line1 line2)
(progn
(list
(nth 0 line1)
(nth 1 line1)
(nth 2 line1)
(concatenate 'string (nth 3 line1) ", " (nth 3 line2))
(concatenate 'string (nth 4 line1) ", " (nth 4 line2)))))
(push (pop x) y)
(defun queuer (data result)
(loop do
(let ((line1 (pop data))
(line2 (pop result)))
(if (equal (first line1) (first line2))
(progn
(push (aggregate line1 line2) result)
(print "=="))
(progn
(push line2 result)
(push line1 result)
(print "<>"))))
while data))
感谢您提供任何见解。
【问题讨论】:
标签: lisp common-lisp