home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
pub
/
scripts
/
ckermit
/
easter2
< prev
next >
Wrap
Lisp/Scheme
|
2020-01-01
|
1KB
|
33 lines
#!/usr/local/bin/kermit +
#
# e a s t e r - Calculates date of Easter for any year between 1900 and 2099.
#
# Usage: easter <year>
# Example: easter 2006
# C-Kermit 8.0.212 or later required.
# Reference: Scientific American, March 2001, p.80.
#
# Illustrates: kerbang scripts, S-Expressions, compound IF conditions,
# array initialization, SET SEXP TRUNCATE ON to force all results to integer.
# First version of this script needed nine TRUNCATE operators.
#
# Author: F. da Cruz, Columbia University, March 2001
# Updated: March 2006.
#
set sexp truncate on
dcl \&m[] = Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
if ( not def \%1 || not numeric \%1 ) exit 1 Usage: \%0 year
if ( < \%1 1900 || > \%1 2099 ) exit 1 "\%0: 1900 <= year < 2100"
(setq x \%1)
(setq a (mod x 19) b (/ x 100) c (mod x 100))
(setq d (/ b 4) e (mod b 4))
(setq g (/ (+ (* 8 b) 13) 25))
(setq h (mod (+ (* a 19) b (- d) (- g) 15) 30))
(setq m (/ (+ a (* h 11)) 319))
(setq j (/ c 4) k (mod c 4))
(setq l (mod (+ (* 2 e) (* 2 j) m (- k) (- h) 32) 7))
(setq n (/ (+ h (- m) l 90) 25))
(setq p (mod (+ h (- m) l n 19) 32))
echo \fday(\m(x)\flpad(\m(n),2,0)\flpad(\m(p),2,0)) \m(p) \&m[n] \m(x)
exit