[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27584: 26.0.50; alist-get: Add optional arg TESTFN
From: |
Nicolas Petton |
Subject: |
bug#27584: 26.0.50; alist-get: Add optional arg TESTFN |
Date: |
Wed, 05 Jul 2017 11:19:20 +0200 |
Tino Calancha <tino.calancha@gmail.com> writes:
> Consider the following question:
> https://emacs.stackexchange.com/questions/33892/replace-element-of-alist-using-equal-even-if-key-does-not-exist/33893#33893
>
> 1. The OP wants to update an alist without adding duplicates,
> 2. but he doesn't want to restrict the lookup in the alist to 'eq'.
>
> The OP realized that
>
> (setf (alist-get key alist) val)
>
> is not an option because, `alist-get' assumes 'eq' in the lookup.
> Then he writes his own function:
> ;; docstrig omitted:
> (defun alist-set (key val alist &optional symbol)
> (if-let ((pair (if symbol (assq key alist) (assoc key alist))))
> (setcdr pair val)
> (push (cons key val) alist))
> alist)
>
> * In the same thread, Drew suggests to add an optional arg TESTFN in
> `alist-get'.
> * We might also tweak `map.el' so that the following code works:
Thanks, I like your changes. If this is going to be installed, could
you add tests to map-tests.el as well?
Cheers,
Nico
signature.asc
Description: PGP signature
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Tino Calancha, 2017/07/04
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Tino Calancha, 2017/07/05
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN,
Nicolas Petton <=
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Tino Calancha, 2017/07/05
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Tino Calancha, 2017/07/06
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Stefan Monnier, 2017/07/06
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Tino Calancha, 2017/07/06
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Nicolas Petton, 2017/07/06
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Tino Calancha, 2017/07/06
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Nicolas Petton, 2017/07/06
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Stefan Monnier, 2017/07/06
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Tino Calancha, 2017/07/07
- bug#27584: 26.0.50; alist-get: Add optional arg TESTFN, Eli Zaretskii, 2017/07/07