Questions tagged «association-lists»

5
如何替换列表元素?
默认情况下,我在auto-mode-alist: ("\\.js\\'" . javascript-mode) (即使使用emacs -Q)。我想替代js2-mode的javascript-mode。当然,我可以使用assq-delete-all,然后add-to-list再次,但我不知道是否有没有更好的办法。 编辑:我明确不想使用自定义,我更喜欢init.el自己动手。

1
'(a。b)确实是列表吗?
我对.表示法感到困惑。是'(a . b)清单吗? (listp '(a . b))返回,t但是当我想知道它的长度(length '(a . b))给出一个错误时Wrong type argument: listp, b。其他功能也一样,nth,mapcar它们都给出相同的错误 是否可以区分'(a b)和的任何功能'(a . b)? 上下文:我想实现的递归版本时遇到此问题mapcar。这是我的实现 (defun true-listp (object) "Return non-`nil' if OBJECT is a true list." (and (listp object) (null (cdr (last object))))) (defun recursive-mapcar (func list) "Evaluates func on elements of the list, then on …

3
检索嵌套的assoc列表中的值的最佳方法?
假设我有一个这样的assoc列表: (setq x '((foo . ((bar . "llama") (baz . "monkey"))))) 我想要的价值bar。我可以做这个: (assoc-default 'bar (assoc-default 'foo x)) 但是我真正想要的是可以接受多个键的东西,例如 (assoc-multi-key 'foo 'bar x) 这样的东西是否存在,也许在某个地方的包装中?我敢肯定我会写的,但是我觉得我的Google-fu只是失败了,我找不到它。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.