diff 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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/base/database/charm/functions.lisp	Thu Sep 30 15:35:15 2010 +0100
@@ -0,0 +1,33 @@
+(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)))