Mercurial > hg > amuse
comparison base/database/charm/functions.lisp @ 318:c4e792b9b898
Add some ideas for charm constituents.
Not particularly useful in its own right, but contains some possibly
useful ideas related to the generalisation of db-compositions.
| author | Jamie Forth <j.forth@gold.ac.uk> |
|---|---|
| date | Thu, 30 Sep 2010 15:35:15 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 317:46dd71ef9ab3 | 318:c4e792b9b898 |
|---|---|
| 1 (in-package #:amuse-charm) | |
| 2 | |
| 3 ;;;===================================================================== | |
| 4 ;;; Helpful functions | |
| 5 ;;;===================================================================== | |
| 6 | |
| 7 (defun find-first-onset (events) | |
| 8 (reduce #'min events :key #'timepoint)) | |
| 9 | |
| 10 (defun find-last-offset (events) | |
| 11 (reduce #'max events :key #'(lambda (event) | |
| 12 (timepoint (cut-off event))))) | |
| 13 | |
| 14 (defgeneric object->db-string (o)) | |
| 15 | |
| 16 (defmethod object->db-string ((o charm-property-list)) | |
| 17 (format nil "~S" (%list-slot-sequence-data o))) | |
| 18 | |
| 19 (defmethod object->db-string ((o event-identifier)) | |
| 20 "This was an earlier approach, that was probably bad." | |
| 21 "e") | |
| 22 | |
| 23 (defmethod object->db-string ((o constituent-identifier)) | |
| 24 "This was an earlier approach, that was probably bad." | |
| 25 "c") | |
| 26 | |
| 27 (defun recompute-constituent-timepoint (constituent) | |
| 28 (setf (timepoint constituent) | |
| 29 (reduce #'min constituent :key 'timepoint))) | |
| 30 | |
| 31 (defun recompute-constituent-duration (constituent) | |
| 32 (setf (duration constituent) | |
| 33 (reduce #'max constituent :key 'timepoint))) |
