diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/base/charm/functions.lisp	Thu Feb 24 11:23:18 2011 +0000
@@ -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)))