picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

commit 75cd33138f81406b08c028f9fa50ad15c6420b22
parent 9c6a030b8042a31d08c36c77d1adb5e65f194a27
Author: Alexander Burger <abu@software-lab.de>
Date:   Thu, 16 Jun 2011 11:34:00 +0200

Split "misc/piDigits.l" from "misc/pi.l"
Diffstat:
Mmisc/pi.l | 27+--------------------------
Amisc/piDigits.l | 28++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/misc/pi.l b/misc/pi.l @@ -1,4 +1,4 @@ -# 03may11abu +# 16jun11abu # (c) Software Lab. Alexander Burger ############################## @@ -21,28 +21,3 @@ (test 3141592653589793238462643383279502884197169399375105820975043 (pi 60) ) - - -################################### -# Spigot algorithm (Jeremy Gibbons) -# Print next digit of PI (unbounded) - -(de piDigit () - (job '((Q . 1) (R . 0) (S . 1) (K . 1) (N . 3) (L . 3)) - (while (>= (- (+ R (* 4 Q)) S) (* N S)) - (mapc set '(Q R S K N L) - (list - (* Q K) - (* L (+ R (* 2 Q))) - (* S L) - (inc K) - (/ (+ (* Q (+ 2 (* 7 K))) (* R L)) (* S L)) - (+ 2 L) ) ) ) - (prog1 N - (let M (- (/ (* 10 (+ R (* 3 Q))) S) (* 10 N)) - (setq Q (* 10 Q) R (* 10 (- R (* N S))) N M) ) ) ) ) - -(prin (piDigit) ".") -(loop - (prin (piDigit)) - (flush) ) diff --git a/misc/piDigits.l b/misc/piDigits.l @@ -0,0 +1,28 @@ +# 16jun11abu +# (c) Software Lab. Alexander Burger + +# Spigot algorithm (Jeremy Gibbons) + +# Print next digit of PI (unbounded) +(de piDigit () + (job '((Q . 1) (R . 0) (S . 1) (K . 1) (N . 3) (L . 3)) + (while (>= (- (+ R (* 4 Q)) S) (* N S)) + (mapc set '(Q R S K N L) + (list + (* Q K) + (* L (+ R (* 2 Q))) + (* S L) + (inc K) + (/ (+ (* Q (+ 2 (* 7 K))) (* R L)) (* S L)) + (+ 2 L) ) ) ) + (prog1 N + (let M (- (/ (* 10 (+ R (* 3 Q))) S) (* 10 N)) + (setq Q (* 10 Q) R (* 10 (- R (* N S))) N M) ) ) ) ) + +# Print _all_ digits of PI +(prin (piDigit) ".") +(loop + (prin (piDigit)) + (flush) ) + +# vi:et:ts=3:sw=3