about summary refs log tree commit diff stats
path: root/free-fall.lsp
blob: a7cd918a6306c70be0d80c153a573a38d2852c43 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
;; TODO: air resistance, terminal velocity
(defconstant +g+ 9.81)
(defglobal *alt* 20000)
(defglobal *v* 0)
(defun step ()
   (setq *alt* (- *alt* *v*))
   (setq *v* (+ *v* +g+))
   (format (standard-output) "~A~%" *alt*))
(defun my-main ()
   (while (> *alt* 0)
	  (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)))