Browse Source

Added in ahnentafel numbering generator

Samuel W. Flint 8 years ago
parent
commit
84df2aa607
1 changed files with 24 additions and 0 deletions
  1. 24 0
      cl-genealogy.org

+ 24 - 0
cl-genealogy.org

@@ -348,6 +348,30 @@ As LambdaLite is schemaless, the following attributes can be mixed in to other t
 :CREATED:  <2016-01-06 Wed 14:35>
 :END:
 
+#+Caption: Ahnentafel Numbering
+#+Name: ahnentafel-numbers
+#+BEGIN_SRC lisp
+  (defun generate-ahnentafel-numbers (starting-person number-of-generations)
+    (let ((ahnentafel-list (cons (cons 1 starting-person) nil)))
+      (labels ((generate-number (current gender)
+                 (if (string= gender "M")
+                     (* 2 current)
+                     (1+ (* 2 current))))
+               (recurse (person number generation gender)
+                 (if (not (= generation 0))
+                     (let ((new-number (generate-number number gender))
+                           (father (:/father person))
+                           (mother (:/mother person)))
+                       (push (cons new-number person) ahnentafel-list)
+                       (if (not (= 0 father))
+                           (recurse father new-number (1- generation) "M"))
+                       (if (not (= 0 mother))
+                           (recurse mother new-number (1- generation) "F"))))))
+        (recurse (:/father starting-person) 1 (1- number-of-generations) "M")
+        (recurse (:/mother starting-person) 1 (1- number-of-generations) "F"))
+      ahnentafel-list))
+#+END_SRC
+
 ** TODO Formatting
 :PROPERTIES:
 :CREATED:  <2016-01-06 Wed 14:35>