diff options
author | Darren Bane <darren.bane@emdalo.com> | 2020-05-27 00:00:36 +0100 |
---|---|---|
committer | Darren Bane <darren.bane@emdalo.com> | 2020-05-27 00:00:36 +0100 |
commit | 01b139cac8273892b4b66057f9da67e9f58d8c39 (patch) | |
tree | b174c69605bd429251756d2abc9096a28b7d5557 /free-fall.lsp | |
parent | e86f1d02e4c79f6083fd35c851b91f80f9d64cea (diff) | |
download | lsp-01b139cac8273892b4b66057f9da67e9f58d8c39.tar.gz |
A bit more Newtonian physics :-)
Diffstat (limited to 'free-fall.lsp')
-rw-r--r-- | free-fall.lsp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/free-fall.lsp b/free-fall.lsp new file mode 100644 index 0000000..27dec85 --- /dev/null +++ b/free-fall.lsp @@ -0,0 +1,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))) |