From e80797b8deb7c51c8490f2d24fa48ef95e061a22 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Mon, 9 May 2022 23:34:01 -0400 Subject: [PATCH] REF make key functions more concise --- local/lib/org-x/org-x-dag.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/local/lib/org-x/org-x-dag.el b/local/lib/org-x/org-x-dag.el index 523bbc3..3861b40 100644 --- a/local/lib/org-x/org-x-dag.el +++ b/local/lib/org-x/org-x-dag.el @@ -1406,7 +1406,7 @@ deadline (eg via epoch time) or if it has a repeater." (defun org-x-dag-ns-epg (adjlist links ns) (-let (((&alist :lifetime ht-l) ns)) (org-x-dag-ns-with-valid ns adjlist :endpoint links - `((:lifetime (lambda (id) (org-x-dag-ns-is-leaf-p ,adjlist id))) + `((:lifetime ,(-partial #'org-x-dag-ns-is-leaf-p adjlist)) (:endpoint)) (lambda (id this-h res) (-let* (((&alist :lifetime l) res) @@ -1422,10 +1422,11 @@ deadline (eg via epoch time) or if it has a repeater." (either-from* x nil (plist-get it key)))) (defun org-x-dag-ns-qtp (adjlist links ns) - (-let (((&alist :lifetime ht-l :endpoint ht-e) ns)) + (-let (((&alist :lifetime ht-l :endpoint ht-e) ns) + (is-leaf-p (-partial #'org-x-dag-ns-is-leaf-p adjlist))) (org-x-dag-ns-with-valid ns adjlist :quarterly links - `((:lifetime (lambda (id) (org-x-dag-ns-is-leaf-p ,adjlist id))) - (:endpoint (lambda (id) (org-x-dag-ns-is-leaf-p ,adjlist id)))) + `((:lifetime ,is-leaf-p) + (:endpoint ,is-leaf-p)) (lambda (id this-h res) (-let (((&alist :lifetime l :endpoint e) res)) (ht-set this-h id (either :right `(:committed (,@e ,@l)))) @@ -1437,7 +1438,7 @@ deadline (eg via epoch time) or if it has a repeater." (defun org-x-dag-ns-wkp (adjlist links ns) (-let (((&alist :quarterly ht-q) ns)) (org-x-dag-ns-with-valid ns adjlist :weekly links - `((:quarterly (lambda (id) (org-x-dag-ns-is-leaf-p ,adjlist id)))) + `((:quarterly ,(-partial #'org-x-dag-ns-is-leaf-p adjlist))) (lambda (id this-h res) (-let (((&alist :quarterly q) res)) (ht-set this-h id (either :right `(:committed ,q))) @@ -1453,6 +1454,7 @@ deadline (eg via epoch time) or if it has a repeater." :survival ht-s :quarterly ht-q) ns) + (is-leaf-p (-partial #'org-x-dag-ns-is-leaf-p adjlist)) (q-committed (->> (ht->alist ht-q) (--map (cons (car it) @@ -1479,9 +1481,9 @@ deadline (eg via epoch time) or if it has a repeater." (-map #'car) (org-x-dag-ht-add-links id ht-q :scheduled-actions))))))) (org-x-dag-ns-with-valid ns adjlist :action links - `((:survival (lambda (id) (org-x-dag-ns-is-leaf-p ,adjlist id))) + `((:survival ,is-leaf-p) (:endpoint ,is-committed-leaf-p) - (:lifetime (lambda (id) (org-x-dag-ns-is-leaf-p ,adjlist id)))) + (:lifetime ,is-leaf-p)) (lambda (id this-h res) (-let (((&alist :survival s :endpoint e :lifetime l) res)) (->> (cond