作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用嵌套 plist 来创建对象结构(CLOS 类型),将嵌套的对象传递给它的部分。我想以迭代方式 append 嵌套的 plist,但因此我想在时间和内存方面高效地完成它。
以下示例显示了由于一次迭代而产生的增量:
'(:airframer "Boeing" :type "777" :wing-plist ((:side :left :winglet? nil)
(:side :right :winglet? nil)))
'(:airframer "Boeing" :type "777" :wing-plist ((:type :main-wing :side :left)
(:type :main-wing :side :right)
(:type :stabilizer :size :left)))
fill
用于破坏性。
(defun append-nested-plist (plist key sub-plist)
(let* ((key-pos (position key plist)))
(fill plist (append (getf plist key) (list sub-plist))
:start (+ key-pos 1) :end (+ key-pos 2))))
最佳答案
这个怎么样?
(defun append-nested-plist (plist key sub-plist)
(push-to-end sub-plist (getf plist key))
plist)
(defmacro push-to-end (item place)
`(setf ,place (nconc ,place (list ,item))))
关于nested - 通用 Lisp : Appending a nested plist efficiently,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8505172/
我是一名优秀的程序员,十分优秀!