Some small correction from the imperative to a more functional style

after some reading of sicp
This commit is contained in:
Christian Egli 2010-03-19 17:35:33 +01:00
parent aa1a0daac2
commit 3a30bc763b
1 changed files with 14 additions and 13 deletions

View File

@ -257,17 +257,17 @@ a path to the current task."
(setq previous-level level)
(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
unique id to each resource."
(let (unique-ids
unique-id
resource resolved-resources)
(dolist (resource resources resolved-resources)
(setq unique-id (org-taskjuggler-get-unique-id resource unique-ids))
(push unique-id unique-ids)
(cond
((null resources) nil)
(t
(let* ((resource (car resources))
(unique-id (org-taskjuggler-get-unique-id resource unique-ids)))
(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)
(let ((previous-level 0)
@ -323,11 +323,12 @@ unique id to each resource."
(defun org-taskjuggler-find-task-with-id (id tasks)
"Find ID in tasks. If found return the path of task. Otherwise return nil."
(let ((task-id (cdr (assoc "ID" (car tasks))))
(path (cdr (assoc "path" (car tasks)))))
(cond
((null tasks) nil)
((equal (cdr (assoc "ID" (car tasks))) id)
(cdr (assoc "path" (car tasks))))
(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)
"Return a unique id for an ITEM which can be a task or a resource.