view base/charm/functions.lisp @ 265:b75b45d76e45

add ioi-from-bar method to amuse-mtp
author Jamie Forth <j.forth@gold.ac.uk>
date Sun, 10 Apr 2011 16:59:24 +0100
parents b5ffec94ae6d
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)))