diff --git a/contents/computus/code/elisp/gauss-easter.el b/contents/computus/code/elisp/gauss-easter.el new file mode 100644 index 000000000..681e5f7d9 --- /dev/null +++ b/contents/computus/code/elisp/gauss-easter.el @@ -0,0 +1,37 @@ +(require 'cl-lib) +(require 'subr-x) + +(defun computus (year &optional servois) + "Calculates the day of Easter for a given YEAR. +Also computes its SERVOIS number when non-nil." + (let* ((a (mod year 19)) ; year's position on the 19-year metonic cycle + (k (floor year 100)) ; century index + (p (floor (+ 13 (* 8 k)) 25)) ; shift of metonic cycle, add a day offset every 300 years + (q (floor k 4)) ; correction for non-observed leap days + (m (mod (+ 15 (- p) k (- q)) 30)) ; correction to starting point of calculation each century + (d (mod (+ (* 19 a) m) 30)) ; number of days from March 21st until the full moon + (n (mod (+ 4 k (- q)) 7)) ; century-based offset in weekly calculation + (b (mod year 4)) ; correction for leap days + (c (mod year 7)) ; also a correction for leap days + ; days from d to next Sunday + (e (mod (+ (* 2 b) (* 4 c) (* 6 d) n) 7))) + ; historical corrections for April 26th and 25th + (when (or (and (= d 29) (= e 6)) + (and (= d 28) (= e 6) (> a 10))) + (setq e -1)) + (cl-values + ; determination of the correct month for Easter + (if (> (+ 22 d e) 31) + (format "April %s" (+ d e -9)) + (format "March %s" (+ 22 d e))) + ; optionally return a value for the Servois table + (if servois (mod (+ 21 d) 31))))) + +(princ (format "%s" + (string-join + '("The following are the dates of the Pascal full moon (using Servois\n" + "notation) and the date of Easter for 2020-2030 AD:\n" + "Year Servois number Easter\n")))) +(dolist (year (number-sequence 2020 2030)) + (cl-multiple-value-bind (easter servois) (computus year t) + (princ (format "%-8s%-18s%-s\n" year servois easter)))) diff --git a/contents/computus/computus.md b/contents/computus/computus.md index 0b474c9a9..7ae6e2fa2 100644 --- a/contents/computus/computus.md +++ b/contents/computus/computus.md @@ -328,6 +328,8 @@ For now, we have the code outputting a tuple of $$d$$ and $$e$$, so users can us [import, lang:"javascript"](code/javascript/gauss_easter.js) {% sample lang="typescript" %} [import, lang:"typescript"](code/typescript/gauss_easter.ts) +{% sample lang="elisp" %} +[import, lang:"elisp"](code/elisp/gauss-easter.el) {% endmethod %}