;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Use 'our-sample' to find a random value from a distribution. ; To get the last random value: (get-last 'age) ; To reset *static*: (reset-sample 'age) ; IMPORTANT: ; Must use the 'define' function before you can use 'our-sample'. ; To use: e.g. (our-sample 'age) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (let ((*static* (make-hash-table)) (*clamp* (make-hash-table))) (defun our-sample (name &optional samp-int) (let ((our-val (list (nDecimal (newSample name samp-int) 4)))) (progn (setf (gethash name *static*) (append our-val nil)) (first our-val)))) (defun reset-sample(name) (setf (gethash name *static*) nil)) (defun reset-all-sample () (setf *static* (make-hash-table)) (setf *clamp* (make-hash-table))) (defun reset-all-unclamped-sample () (setf *static* (make-hash-table)) (maphash #'(lambda (k v) (setf (gethash k *static*) v)) *clamp*)) ;To get the last random from a define (defun get-last (name) (first(gethash name *static*))) (defun get-static (name) (if (gethash name *static*) (get-last name) (our-sample name))) (defun getClamp () (let (lst) (maphash #'(lambda (k v) (push (list k (first v)) lst)) *clamp*) lst)) (defun getStatic () (let (lst) (maphash #'(lambda (k v) (push (list k (first v)) lst)) *static*) lst)) (defun clampValue (names &key reset) (if reset (reset-all-sample)) ;(showh *static*) (dolist (val names) (setf (gethash (first val) *static*) (list (second val))) (setf (gethash (first val) *clamp*) (list (second val))))))