Mercurial > hg > amuse
annotate base/charm/functions.lisp @ 253:b5ffec94ae6d
some very sketchy Charm constituent code
author | Jamie Forth <j.forth@gold.ac.uk> |
---|---|
date | Thu, 24 Feb 2011 11:23:18 +0000 |
parents | |
children |
rev | line source |
---|---|
j@253 | 1 (in-package #:amuse-charm) |
j@253 | 2 |
j@253 | 3 ;;;===================================================================== |
j@253 | 4 ;;; Helpful functions |
j@253 | 5 ;;;===================================================================== |
j@253 | 6 |
j@253 | 7 (defun find-first-onset (events) |
j@253 | 8 (reduce #'min events :key #'timepoint)) |
j@253 | 9 |
j@253 | 10 (defun find-last-offset (events) |
j@253 | 11 (reduce #'max events :key #'(lambda (event) |
j@253 | 12 (timepoint (cut-off event))))) |
j@253 | 13 |
j@253 | 14 (defgeneric object->db-string (o)) |
j@253 | 15 |
j@253 | 16 (defmethod object->db-string ((o charm-property-list)) |
j@253 | 17 (format nil "~S" (%list-slot-sequence-data o))) |
j@253 | 18 |
j@253 | 19 (defmethod object->db-string ((o event-identifier)) |
j@253 | 20 "This was an earlier approach, that was probably bad." |
j@253 | 21 "e") |
j@253 | 22 |
j@253 | 23 (defmethod object->db-string ((o constituent-identifier)) |
j@253 | 24 "This was an earlier approach, that was probably bad." |
j@253 | 25 "c") |
j@253 | 26 |
j@253 | 27 (defun recompute-constituent-timepoint (constituent) |
j@253 | 28 (setf (timepoint constituent) |
j@253 | 29 (reduce #'min constituent :key 'timepoint))) |
j@253 | 30 |
j@253 | 31 (defun recompute-constituent-duration (constituent) |
j@253 | 32 (setf (duration constituent) |
j@253 | 33 (reduce #'max constituent :key 'timepoint))) |