emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/taxy f4993f2 10/10: Docs: Fix example, tidy


From: ELPA Syncer
Subject: [elpa] externals/taxy f4993f2 10/10: Docs: Fix example, tidy
Date: Sun, 29 Aug 2021 04:57:22 -0400 (EDT)

branch: externals/taxy
commit f4993f216f3bb9ec9fdebfc9ab3643128ce9b995
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Docs: Fix example, tidy
---
 README.org | 176 +++++++++++++++++++++++++++++-----------------------------
 taxy.info  | 184 ++++++++++++++++++++++++++++++++-----------------------------
 2 files changed, 185 insertions(+), 175 deletions(-)

diff --git a/README.org b/README.org
index 83e9f20..81be48f 100644
--- a/README.org
+++ b/README.org
@@ -145,18 +145,21 @@ The ~taxy-fill~ function applies the numbers in a 
"cascade" down the hierarchy o
 
 ** Lettery (filling incrementally)
 
-You can also add more objects after the hierarchy has been filled:
+You can also add more objects after the hierarchy has been filled.  In this 
example we'll make a comprehensive taxonomy of letters.  The first sub-taxy 
collects vowels, and the second, by leaving its predicate at the default value, 
~identity~, collects all letters not collected by the first taxy, i.e. 
non-vowels.
 
 #+BEGIN_SRC elisp
   (defvar lettery
-    (make-taxy :name "Lettery"
-               :description "A comprehensive taxonomy of letters."
-               :taxys (list (make-taxy :name "Vowels"
-                                       :description "You know what those are."
-                                       :predicate (lambda (l)
-                                                    (member-ignore-case l 
'("a" "e" "i" "o" "u"))))
-                            (make-taxy :name "Consonants"
-                                       :description "Well, if they aren't a 
vowel..."))))
+    (make-taxy
+     :name "Lettery"
+     :description "A comprehensive taxonomy of letters."
+     :taxys (list (make-taxy
+                   :name "Vowels"
+                   :description "You know what those are."
+                   :predicate (lambda (l)
+                                (member-ignore-case l '("a" "e" "i" "o" "u"))))
+                  (make-taxy
+                   :name "Consonants"
+                   :description "Well, if they aren't vowels..."))))
 
   (taxy-plain
    (taxy-fill (reverse
@@ -165,6 +168,8 @@ You can also add more objects after the hierarchy has been 
filled:
               lettery))
 #+END_SRC
 
+That produces:
+
 #+BEGIN_SRC elisp
   ("Lettery" "A comprehensive taxonomy of letters."
    (("Vowels" "You know what those are."
@@ -183,6 +188,8 @@ Oops, we forgot the letters after N!  Let's add them, too:
               lettery))
 #+END_SRC
 
+Which gives us:
+
 #+BEGIN_SRC elisp
   ("Lettery" "A comprehensive taxonomy of letters."
    (("Vowels" "You know what those are."
@@ -193,12 +200,13 @@ Oops, we forgot the letters after N!  Let's add them, too:
 
 Oh, they're out of order, now.  That won't do.  Let's fix that:
 
-#+BEGIN_SRC elisp
-  (cl-loop for taxy in-ref (taxy-taxys lettery)
-           do (setf (taxy-objects taxy) (cl-sort (taxy-objects taxy) #'<
-                                                 :key #'string-to-char)))
-
-  (taxy-plain lettery)
+#+BEGIN_SRC elisp :exports code :results code
+  (taxy-plain
+   (taxy-mapc* (lambda (taxy)
+                 (setf (taxy-objects taxy)
+                       (cl-sort (taxy-objects taxy) #'<
+                                :key #'string-to-char)))
+     lettery))
 #+END_SRC
 
 That's better:
@@ -275,20 +283,19 @@ And finally we'll define a taxy to organize them.  In 
this, we use a helper macr
                          (when (member ,needle (funcall ,haystack object))
                            ,needle))))
       (make-taxy
-       :taxys (list (make-taxy
-                     :name "Sporty"
-                     :take (lambda (object taxy)
-                             (taxy-take-keyed
-                              (list #'sport-venue
-                                    (in 'ball 'sport-uses)
-                                    (in 'disc 'sport-uses)
-                                    (in 'glove 'sport-uses)
-                                    (in 'racket 'sport-uses))
-                              object taxy
-                              ;; We set the `:then' function of the taxys
-                              ;; created by `taxy-take-keyed' to `identity'
-                              ;; so they will not consume their objects.
-                              :then #'identity)))))))
+       :name "Sporty"
+       :take (lambda (object taxy)
+               (taxy-take-keyed
+                 (list #'sport-venue
+                       (in 'ball 'sport-uses)
+                       (in 'disc 'sport-uses)
+                       (in 'glove 'sport-uses)
+                       (in 'racket 'sport-uses))
+                 object taxy
+                 ;; We set the `:then' function of the taxys
+                 ;; created by `taxy-take-keyed' to `identity'
+                 ;; so they will not consume their objects.
+                 :then #'identity)))))
 #+END_SRC
 
 Now let's fill the taxy with the sports and format it:
@@ -302,28 +309,26 @@ Now let's fill the taxy with the sports and format it:
 #+END_SRC
 
 #+BEGIN_SRC elisp :exports code
-((("Sporty"
-   ((disc
-     ((outdoor
-       ("Ultimate" "Disc golf"))))
-    (ball
-     ((racket
-       ((indoor
-         ("Racquetball"))
-        (outdoor
-         ("Tennis"))))
-      (indoor
-       ("Volleyball" "Basketball"))
+  ((("Sporty"
+     ((indoor
+       ((ball
+         ("Volleyball" "Basketball")
+         ((glove
+           ("Handball"))
+          (racket
+           ("Racquetball"))))))
       (outdoor
-       ("Soccer" "Football"))
-      (glove
-       ((indoor
-         ("Handball"))
-        (outdoor
-         ("Baseball"))))))))))
+       ((disc
+         ("Ultimate" "Disc golf"))
+        (ball
+         ("Soccer" "Football")
+         ((racket
+           ("Tennis"))
+          (glove
+           ("Baseball"))))))))))
 #+END_SRC
 
-That's pretty sporty.  But classifying them by venue first makes the racket 
and glove sports not be listed together.  Let's swap that around:
+That's pretty sporty.  But classifying them by venue first makes the racket 
and glove sports not be listed together.  Let's swap the key functions around 
so the venue is classified at the deepest level of the hierarchy:
 
 #+BEGIN_SRC elisp :exports code :results silent
   (defvar sporty
@@ -332,17 +337,16 @@ That's pretty sporty.  But classifying them by venue 
first makes the racket and
                          (when (member ,needle (funcall ,haystack object))
                            ,needle))))
       (make-taxy
-       :taxys (list (make-taxy
-                     :name "Sporty"
-                     :take (lambda (object taxy)
-                             (taxy-take-keyed
-                              (list (in 'ball 'sport-uses)
-                                    (in 'disc 'sport-uses)
-                                    (in 'glove 'sport-uses)
-                                    (in 'racket 'sport-uses)
-                                    #'sport-venue)
-                              object taxy
-                              :then #'identity)))))))
+       :name "Sporty"
+       :take (lambda (object taxy)
+               (taxy-take-keyed
+                 (list (in 'ball 'sport-uses)
+                       (in 'disc 'sport-uses)
+                       (in 'glove 'sport-uses)
+                       (in 'racket 'sport-uses)
+                       #'sport-venue)
+                 object taxy
+                 :then #'identity)))))
 
   (thread-last sporty
     taxy-emptied
@@ -352,25 +356,25 @@ That's pretty sporty.  But classifying them by venue 
first makes the racket and
 #+END_SRC
 
 #+BEGIN_SRC elisp :exports code
-((("Sporty"
-   ((disc
-     ((outdoor
-       ("Ultimate" "Disc golf"))))
-    (ball
-     ((racket
-       ((indoor
-         ("Racquetball"))
-        (outdoor
-         ("Tennis"))))
-      (indoor
-       ("Volleyball" "Basketball"))
-      (outdoor
-       ("Soccer" "Football"))
-      (glove
-       ((indoor
-         ("Handball"))
+  ((("Sporty"
+     ((disc
+       ((outdoor
+         ("Ultimate" "Disc golf"))))
+      (ball
+       ((racket
+         ((indoor
+           ("Racquetball"))
+          (outdoor
+           ("Tennis"))))
+        (indoor
+         ("Volleyball" "Basketball"))
         (outdoor
-         ("Baseball"))))))))))
+         ("Soccer" "Football"))
+        (glove
+         ((indoor
+           ("Handball"))
+          (outdoor
+           ("Baseball"))))))))))
 #+END_SRC
 
 That's better.  But I'd also like to see a very simple classification to help 
me decide what to play:
@@ -378,16 +382,14 @@ That's better.  But I'd also like to see a very simple 
classification to help me
 #+BEGIN_SRC elisp :exports code
   (thread-last
       (make-taxy
-       :taxys (list
-               (make-taxy
-                :name "Funny"
-                :take (lambda (object taxy)
-                        (taxy-take-keyed
-                         (list (lambda (sport)
-                                 (if (sport-fun sport)
-                                     'fun 'boring))
-                               #'sport-venue)
-                         object taxy)))))
+       :name "Funny"
+       :take (lambda (object taxy)
+               (taxy-take-keyed
+                 (list (lambda (sport)
+                         (if (sport-fun sport)
+                             'fun 'boring))
+                       #'sport-venue)
+                 object taxy)))
     taxy-emptied
     (taxy-fill sports)
     (taxy-mapcar #'sport-name)
diff --git a/taxy.info b/taxy.info
index 3270b87..0d967e8 100644
--- a/taxy.info
+++ b/taxy.info
@@ -204,17 +204,24 @@ File: README.info,  Node: Lettery (filling 
incrementally),  Next: Sporty (unders
 1.2 Lettery (filling incrementally)
 ===================================
 
-You can also add more objects after the hierarchy has been filled:
+You can also add more objects after the hierarchy has been filled.  In
+this example we’ll make a comprehensive taxonomy of letters.  The first
+sub-taxy collects vowels, and the second, by leaving its predicate at
+the default value, ‘identity’, collects all letters not collected by the
+first taxy, i.e.  non-vowels.
 
      (defvar lettery
-       (make-taxy :name "Lettery"
-                  :description "A comprehensive taxonomy of letters."
-                  :taxys (list (make-taxy :name "Vowels"
-                                          :description "You know what those 
are."
-                                          :predicate (lambda (l)
-                                                       (member-ignore-case l 
'("a" "e" "i" "o" "u"))))
-                               (make-taxy :name "Consonants"
-                                          :description "Well, if they aren't a 
vowel..."))))
+       (make-taxy
+        :name "Lettery"
+        :description "A comprehensive taxonomy of letters."
+        :taxys (list (make-taxy
+                      :name "Vowels"
+                      :description "You know what those are."
+                      :predicate (lambda (l)
+                                   (member-ignore-case l '("a" "e" "i" "o" 
"u"))))
+                     (make-taxy
+                      :name "Consonants"
+                      :description "Well, if they aren't vowels..."))))
 
      (taxy-plain
       (taxy-fill (reverse
@@ -222,6 +229,8 @@ You can also add more objects after the hierarchy has been 
filled:
                            collect (upcase (char-to-string l))))
                  lettery))
 
+   That produces:
+
      ("Lettery" "A comprehensive taxonomy of letters."
       (("Vowels" "You know what those are."
         ("A" "E" "I"))
@@ -236,6 +245,8 @@ You can also add more objects after the hierarchy has been 
filled:
                            collect (upcase (char-to-string l))))
                  lettery))
 
+   Which gives us:
+
      ("Lettery" "A comprehensive taxonomy of letters."
       (("Vowels" "You know what those are."
         ("O" "U" "A" "E" "I"))
@@ -244,11 +255,12 @@ You can also add more objects after the hierarchy has 
been filled:
 
    Oh, they’re out of order, now.  That won’t do.  Let’s fix that:
 
-     (cl-loop for taxy in-ref (taxy-taxys lettery)
-              do (setf (taxy-objects taxy) (cl-sort (taxy-objects taxy) #'<
-                                                    :key #'string-to-char)))
-
-     (taxy-plain lettery)
+     (taxy-plain
+      (taxy-mapc* (lambda (taxy)
+                    (setf (taxy-objects taxy)
+                          (cl-sort (taxy-objects taxy) #'<
+                                   :key #'string-to-char)))
+        lettery))
 
    That’s better:
 
@@ -324,20 +336,19 @@ key functions:
                             (when (member ,needle (funcall ,haystack object))
                               ,needle))))
          (make-taxy
-          :taxys (list (make-taxy
-                        :name "Sporty"
-                        :take (lambda (object taxy)
-                                (taxy-take-keyed
-                                 (list #'sport-venue
-                                       (in 'ball 'sport-uses)
-                                       (in 'disc 'sport-uses)
-                                       (in 'glove 'sport-uses)
-                                       (in 'racket 'sport-uses))
-                                 object taxy
-                                 ;; We set the `:then' function of the taxys
-                                 ;; created by `taxy-take-keyed' to `identity'
-                                 ;; so they will not consume their objects.
-                                 :then #'identity)))))))
+          :name "Sporty"
+          :take (lambda (object taxy)
+                  (taxy-take-keyed
+                    (list #'sport-venue
+                          (in 'ball 'sport-uses)
+                          (in 'disc 'sport-uses)
+                          (in 'glove 'sport-uses)
+                          (in 'racket 'sport-uses))
+                    object taxy
+                    ;; We set the `:then' function of the taxys
+                    ;; created by `taxy-take-keyed' to `identity'
+                    ;; so they will not consume their objects.
+                    :then #'identity)))))
 
    Now let’s fill the taxy with the sports and format it:
 
@@ -348,27 +359,27 @@ key functions:
        taxy-plain)
 
      ((("Sporty"
-        ((disc
-          ((outdoor
-            ("Ultimate" "Disc golf"))))
-         (ball
-          ((racket
-            ((indoor
-              ("Racquetball"))
-             (outdoor
-              ("Tennis"))))
-           (indoor
-            ("Volleyball" "Basketball"))
-           (outdoor
-            ("Soccer" "Football"))
-           (glove
-            ((indoor
+        ((indoor
+          ((ball
+            ("Volleyball" "Basketball")
+            ((glove
               ("Handball"))
-             (outdoor
+             (racket
+              ("Racquetball"))))))
+         (outdoor
+          ((disc
+            ("Ultimate" "Disc golf"))
+           (ball
+            ("Soccer" "Football")
+            ((racket
+              ("Tennis"))
+             (glove
               ("Baseball"))))))))))
 
    That’s pretty sporty.  But classifying them by venue first makes the
-racket and glove sports not be listed together.  Let’s swap that around:
+racket and glove sports not be listed together.  Let’s swap the key
+functions around so the venue is classified at the deepest level of the
+hierarchy:
 
      (defvar sporty
        (cl-macrolet ((in (needle haystack)
@@ -376,17 +387,16 @@ racket and glove sports not be listed together.  Let’s 
swap that around:
                             (when (member ,needle (funcall ,haystack object))
                               ,needle))))
          (make-taxy
-          :taxys (list (make-taxy
-                        :name "Sporty"
-                        :take (lambda (object taxy)
-                                (taxy-take-keyed
-                                 (list (in 'ball 'sport-uses)
-                                       (in 'disc 'sport-uses)
-                                       (in 'glove 'sport-uses)
-                                       (in 'racket 'sport-uses)
-                                       #'sport-venue)
-                                 object taxy
-                                 :then #'identity)))))))
+          :name "Sporty"
+          :take (lambda (object taxy)
+                  (taxy-take-keyed
+                    (list (in 'ball 'sport-uses)
+                          (in 'disc 'sport-uses)
+                          (in 'glove 'sport-uses)
+                          (in 'racket 'sport-uses)
+                          #'sport-venue)
+                    object taxy
+                    :then #'identity)))))
 
      (thread-last sporty
        taxy-emptied
@@ -419,16 +429,14 @@ to help me decide what to play:
 
      (thread-last
          (make-taxy
-          :taxys (list
-                  (make-taxy
-                   :name "Funny"
-                   :take (lambda (object taxy)
-                           (taxy-take-keyed
-                            (list (lambda (sport)
-                                    (if (sport-fun sport)
-                                        'fun 'boring))
-                                  #'sport-venue)
-                            object taxy)))))
+          :name "Funny"
+          :take (lambda (object taxy)
+                  (taxy-take-keyed
+                    (list (lambda (sport)
+                            (if (sport-fun sport)
+                                'fun 'boring))
+                          #'sport-venue)
+                    object taxy)))
        taxy-emptied
        (taxy-fill sports)
        (taxy-mapcar #'sport-name)
@@ -1001,28 +1009,28 @@ Node: Top218
 Node: Examples1506
 Node: Numbery (starting basically)1825
 Node: Lettery (filling incrementally)7584
-Node: Sporty (understanding completely)10033
-Node: Applications16508
-Node: Installation16908
-Node: Usage17209
-Node: Dynamic taxys19330
-Node: Multi-level dynamic taxys21874
-Node: "Chains" of independent multi-level dynamic taxys24071
-Node: Reusable taxys26951
-Node: Threading macros31120
-Node: Modifying filled taxys31659
-Node: Magit section32752
-Node: Changelog33410
-Node: 03-pre33572
-Node: 0233678
-Node: Changes33815
-Node: Additions34099
-Node: Fixes35010
-Node: 0135256
-Node: Development35355
-Node: Copyright assignment35561
-Node: Credits36148
-Node: License36338
+Node: Sporty (understanding completely)10270
+Node: Applications16279
+Node: Installation16679
+Node: Usage16980
+Node: Dynamic taxys19101
+Node: Multi-level dynamic taxys21645
+Node: "Chains" of independent multi-level dynamic taxys23842
+Node: Reusable taxys26722
+Node: Threading macros30891
+Node: Modifying filled taxys31430
+Node: Magit section32523
+Node: Changelog33181
+Node: 03-pre33343
+Node: 0233449
+Node: Changes33586
+Node: Additions33870
+Node: Fixes34781
+Node: 0135027
+Node: Development35126
+Node: Copyright assignment35332
+Node: Credits35919
+Node: License36109
 
 End Tag Table
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]