Some small correction from the imperative to a more functional style
after some reading of sicp
This commit is contained in:
parent
aa1a0daac2
commit
3a30bc763b
|
@ -257,17 +257,17 @@ a path to the current task."
|
||||||
(setq previous-level level)
|
(setq previous-level level)
|
||||||
(setq resolved-tasks (append resolved-tasks (list task)))))))
|
(setq resolved-tasks (append resolved-tasks (list task)))))))
|
||||||
|
|
||||||
(defun org-taskjuggler-assign-resource-ids (resources)
|
(defun org-taskjuggler-assign-resource-ids (resources &optional unique-ids)
|
||||||
"Given a list of resources return the same list, assigning a
|
"Given a list of resources return the same list, assigning a
|
||||||
unique id to each resource."
|
unique id to each resource."
|
||||||
(let (unique-ids
|
(cond
|
||||||
unique-id
|
((null resources) nil)
|
||||||
resource resolved-resources)
|
(t
|
||||||
(dolist (resource resources resolved-resources)
|
(let* ((resource (car resources))
|
||||||
(setq unique-id (org-taskjuggler-get-unique-id resource unique-ids))
|
(unique-id (org-taskjuggler-get-unique-id resource unique-ids)))
|
||||||
(push unique-id unique-ids)
|
|
||||||
(push (cons "unique-id" unique-id) resource)
|
(push (cons "unique-id" unique-id) resource)
|
||||||
(setq resolved-resources (append resolved-resources (list resource))))))
|
(cons resource (org-taskjuggler-assign-resource-ids (cdr resources)
|
||||||
|
(cons unique-id unique-ids)))))))
|
||||||
|
|
||||||
(defun org-taskjuggler-resolve-dependencies (tasks)
|
(defun org-taskjuggler-resolve-dependencies (tasks)
|
||||||
(let ((previous-level 0)
|
(let ((previous-level 0)
|
||||||
|
@ -323,11 +323,12 @@ unique id to each resource."
|
||||||
|
|
||||||
(defun org-taskjuggler-find-task-with-id (id tasks)
|
(defun org-taskjuggler-find-task-with-id (id tasks)
|
||||||
"Find ID in tasks. If found return the path of task. Otherwise return nil."
|
"Find ID in tasks. If found return the path of task. Otherwise return nil."
|
||||||
(cond
|
(let ((task-id (cdr (assoc "ID" (car tasks))))
|
||||||
((null tasks) nil)
|
(path (cdr (assoc "path" (car tasks)))))
|
||||||
((equal (cdr (assoc "ID" (car tasks))) id)
|
(cond
|
||||||
(cdr (assoc "path" (car tasks))))
|
((null tasks) nil)
|
||||||
(t (org-taskjuggler-find-task-with-id id (cdr tasks)))))
|
((equal task-id id) path)
|
||||||
|
(t (org-taskjuggler-find-task-with-id id (cdr tasks))))))
|
||||||
|
|
||||||
(defun org-taskjuggler-get-unique-id (item unique-ids)
|
(defun org-taskjuggler-get-unique-id (item unique-ids)
|
||||||
"Return a unique id for an ITEM which can be a task or a resource.
|
"Return a unique id for an ITEM which can be a task or a resource.
|
||||||
|
|
Loading…
Reference in New Issue