blob: 412b08290c8d867ef27c36a3e0c08bdff1a354a1 (
plain) (
tree)
|
|
;; TODO: air resistance, terminal velocity
(defconstant +G+ 9.81)
(defvar *alt* 20000)
(defvar *v* 0)
(defun one-step ()
(setq *alt* (- *alt* *v*))
(setq *v* (+ *v* +G+))
(format *standard-output* "~A~%" *alt*))
(defun my-main ()
(loop while (> *alt* 0)
do (one-step)))
;;; And here's an example from GNAT:
(defun free-fall ()
(format *standard-output* "Gravitational constant: ~A~%" +G+)
(format *standard-output* "Twice that: ~A~%" (* 2 +G+))
(let* ((time 10)
(distance (* 0.5 +g+ (expt time 2))))
(format *standard-output* "Distance travelled in 10 seconds of free fall: ~A~%" distance)))
|