diff options
author | Darren Bane <darren.bane@emdalo.com> | 2020-08-21 19:40:30 +0100 |
---|---|---|
committer | Darren Bane <darren.bane@emdalo.com> | 2020-08-21 19:40:30 +0100 |
commit | e6931993d7193b60881d0303110974b6af6af852 (patch) | |
tree | c6ace92a2e93aa13f3b44d32439d93fd29bfaacb /cfree-fall.lisp | |
parent | 5c4dfb5d3e84be9f7e4b9ea8383fcb9de70862aa (diff) | |
download | lsp-e6931993d7193b60881d0303110974b6af6af852.tar.gz |
Some more ISLisp->CL examples
Diffstat (limited to 'cfree-fall.lisp')
-rw-r--r-- | cfree-fall.lisp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cfree-fall.lisp b/cfree-fall.lisp new file mode 100644 index 0000000..412b082 --- /dev/null +++ b/cfree-fall.lisp @@ -0,0 +1,19 @@ +;; 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))) |