私は次の一般的な Lisp 関数を持っています:(aggregate line1 line2)
と(queuer data result)
.
queuer
line1
値と最初のフィールドが異なる場合は結果にプッシュする必要line2
があり、最初のフィールドが等しい場合はこれらの2行の集計をプッシュする必要があります。
結果リストが変更されない理由がわかりません。
注:(push (pop data) result)
最初の要素が含まれるように、結果リストを a で初期化しています。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))
洞察をありがとう。