annotate 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 |
|
rev |
line source |
j@318
|
1 (in-package #:amuse-charm)
|
j@318
|
2
|
j@318
|
3 ;;;=====================================================================
|
j@318
|
4 ;;; Helpful functions
|
j@318
|
5 ;;;=====================================================================
|
j@318
|
6
|
j@318
|
7 (defun find-first-onset (events)
|
j@318
|
8 (reduce #'min events :key #'timepoint))
|
j@318
|
9
|
j@318
|
10 (defun find-last-offset (events)
|
j@318
|
11 (reduce #'max events :key #'(lambda (event)
|
j@318
|
12 (timepoint (cut-off event)))))
|
j@318
|
13
|
j@318
|
14 (defgeneric object->db-string (o))
|
j@318
|
15
|
j@318
|
16 (defmethod object->db-string ((o charm-property-list))
|
j@318
|
17 (format nil "~S" (%list-slot-sequence-data o)))
|
j@318
|
18
|
j@318
|
19 (defmethod object->db-string ((o event-identifier))
|
j@318
|
20 "This was an earlier approach, that was probably bad."
|
j@318
|
21 "e")
|
j@318
|
22
|
j@318
|
23 (defmethod object->db-string ((o constituent-identifier))
|
j@318
|
24 "This was an earlier approach, that was probably bad."
|
j@318
|
25 "c")
|
j@318
|
26
|
j@318
|
27 (defun recompute-constituent-timepoint (constituent)
|
j@318
|
28 (setf (timepoint constituent)
|
j@318
|
29 (reduce #'min constituent :key 'timepoint)))
|
j@318
|
30
|
j@318
|
31 (defun recompute-constituent-duration (constituent)
|
j@318
|
32 (setf (duration constituent)
|
j@318
|
33 (reduce #'max constituent :key 'timepoint)))
|