Mercurial > hg > amuse
view 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 |
line wrap: on
line source
(in-package #:amuse-charm) ;;;===================================================================== ;;; Helpful functions ;;;===================================================================== (defun find-first-onset (events) (reduce #'min events :key #'timepoint)) (defun find-last-offset (events) (reduce #'max events :key #'(lambda (event) (timepoint (cut-off event))))) (defgeneric object->db-string (o)) (defmethod object->db-string ((o charm-property-list)) (format nil "~S" (%list-slot-sequence-data o))) (defmethod object->db-string ((o event-identifier)) "This was an earlier approach, that was probably bad." "e") (defmethod object->db-string ((o constituent-identifier)) "This was an earlier approach, that was probably bad." "c") (defun recompute-constituent-timepoint (constituent) (setf (timepoint constituent) (reduce #'min constituent :key 'timepoint))) (defun recompute-constituent-duration (constituent) (setf (duration constituent) (reduce #'max constituent :key 'timepoint)))