This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; in opt.lsp | |
;;; Given argument forms to an arbitrary arity arithmetic function, | |
;;; return new arguments with all constants folded together. | |
;;; FIXME: handler-case, return original arguments | |
;;; if there's an error (e.g. overflow). | |
(defun fold-constants (function argforms env) | |
(loop for form in argforms | |
when (constantp form env) | |
collect (ext:constant-form-value form env) into constants |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-method-combination machine () | |
((start (:start)) | |
(rest *)) | |
(let ((qualifiers (mapcar #'method-qualifiers rest)) | |
(tags (mapcar (lambda (m) (declare (ignore m)) (gensym)) rest))) | |
`(prog (switch) | |
(setf switch | |
(lambda (state) | |
(cond ((equal state nil) (go nil)) | |
,@(loop for qualifier in qualifiers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; public domain, by Bike | |
;;;; Gillespie, Daniel T. (1977). "Exact Stochastic Simulation of Coupled Chemical Reactions". The Journal of Physical Chemistry 81 (25): 2340–2361. doi:10.1021/j100540a008. | |
(defun gillespie (species reactions | |
&key (stop-time 0d0 st-p) (stop-reactions 0 sr-p) | |
(rpd 0 rpd-p)) | |
;; SPECIES is a vector of N positive integers, molecule counts. | |
;; REACTIONS is a vector of M lists | |
;; The first of each list is the rate constant for that reaction. | |
;; The second is a vector of N nonnegative integers describing the substrates. |
NewerOlder