[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/taxy 6c5b7c7 07/39: Add: taxy-apply
From: |
ELPA Syncer |
Subject: |
[elpa] externals/taxy 6c5b7c7 07/39: Add: taxy-apply |
Date: |
Fri, 27 Aug 2021 10:57:30 -0400 (EDT) |
branch: externals/taxy
commit 6c5b7c77d0324cac1fa9ebc2a5a7ba4a1a6a69ca
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
Add: taxy-apply
---
README.org | 2 +-
taxy.el | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/README.org b/README.org
index c06b0f4..0ccb801 100644
--- a/README.org
+++ b/README.org
@@ -131,7 +131,7 @@ The ~:then~ function determines what happens to an object
after being taken in:
After defining a taxy, call ~taxy-fill~ with it and a list of objects to fill
the taxy's hierarchy. *Note:* ~taxy-fill~ modifies the taxy given to it
(filling its ~:objects~ and those of its ~:taxys~), so when using a statically
defined taxy (e.g. one defined with ~defvar~), you should pass ~taxy-fill~ a
taxy copied with ~taxy-copy~, which recursively copies a taxy without
~:objects~.
-To return a taxy in a more human-readable format (with only relevant fields
included), use ~taxy-simple~.
+To return a taxy in a more human-readable format (with only relevant fields
included), use ~taxy-simple~. You may also use ~taxy-apply~ to replace objects
in a taxy with, e.g. a more useful representation.
** Dynamic taxys
diff --git a/taxy.el b/taxy.el
index 115beca..b3bdb3d 100644
--- a/taxy.el
+++ b/taxy.el
@@ -83,6 +83,17 @@ Clears TAXY's objects and those of its descendant taxys."
(taxy-taxys taxy) (mapcar #'taxy-copy (taxy-taxys taxy)))
taxy)
+(defun taxy-apply (fn taxy)
+ "Return TAXY, having applied FN to each object in it, including descendants.
+Used to apply side effects, e.g. to transform objects into a more
+useful form after classification."
+ ;; I can't seem to find a way to do this without consing new lists.
+ ;; Even using `cl-loop' with `in-ref' didn't work.
+ (setf (taxy-objects taxy) (mapcar fn (taxy-objects taxy))
+ (taxy-taxys taxy) (cl-loop for taxy in (taxy-taxys taxy)
+ collect (taxy-apply fn taxy)))
+ taxy)
+
;;;; Footer
(provide 'taxy)
- [elpa] branch externals/taxy created (now 2c044ed), ELPA Syncer, 2021/08/27
- [elpa] externals/taxy dbad5b9 01/39: Let there be taxonomy!, ELPA Syncer, 2021/08/27
- [elpa] externals/taxy 8797141 02/39: Dynamic, consuming, and non-consuming, ELPA Syncer, 2021/08/27
- [elpa] externals/taxy 6c5b7c7 07/39: Add: taxy-apply,
ELPA Syncer <=
- [elpa] externals/taxy 02217c4 11/39: Docs: Add comments, ELPA Syncer, 2021/08/27
- [elpa] externals/taxy 408a32b 09/39: Docs: Tidy, ELPA Syncer, 2021/08/27
- [elpa] externals/taxy 09724dd 10/39: Add: taxy-take-keyed, ELPA Syncer, 2021/08/27
- [elpa] externals/taxy 9d44dba 13/39: Change: taxy-apply -> taxy-map, ELPA Syncer, 2021/08/27
- [elpa] externals/taxy 6eff6ae 18/39: Docs: Put Contents first, ELPA Syncer, 2021/08/27
- [elpa] externals/taxy 0a57638 17/39: Docs: Mention threading macros, ELPA Syncer, 2021/08/27
- [elpa] externals/taxy 0dce844 16/39: Docs: Add example of incremental filling, ELPA Syncer, 2021/08/27
- [elpa] externals/taxy e09dc38 32/39: Add: (taxy-mapc*) And musicy.el example, ELPA Syncer, 2021/08/27
- [elpa] externals/taxy bd28836 24/39: Meta: Headers, ELPA Syncer, 2021/08/27
- [elpa] externals/taxy f0b926f 34/39: Add: Diredy example, ELPA Syncer, 2021/08/27