Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,46 @@
#lang racket
(require racket/date)
; Any CE Year that was the first of a 60-year cycle
(define base-year 1984)
(define celestial-stems '("" "" "" "" "" "" "" "" "" ""))
(define terrestrial-branches '("" "" "" "" "" "" "" "" "" "" "" ""))
(define zodiac-animals
'("Rat" "Ox" "Tiger" "Rabbit" "Dragon" "Snake" "Horse" "Goat" "Monkey" "Rooster" "Dog" "Pig"))
(define elements '("Wood" "Fire" "Earth" "Metal" "Water"))
(define aspects '("yang" "yin"))
(define pinyin
(map cons
(append celestial-stems terrestrial-branches)
(list "jiă" "" "bĭng" "dīng" "" "" "gēng" "xīn" "rén" "gŭi"
"" "chŏu" "yín" "măo" "chén" "" "" "wèi" "shēn" "yŏu" "" "hài")))
(define (this-year) (date-year (current-date)))
(define (pinyin-for han) (cdr (assoc han pinyin)))
(define (han/pinyin-nth n hans) (let ((han (list-ref hans n))) (values han (pinyin-for han))))
(define (chinese-zodiac ce-year)
(let* ((cycle-year (- ce-year base-year))
(stem-number (modulo cycle-year (length celestial-stems)))
(element-number (quotient stem-number 2))
(aspect-number (modulo cycle-year (length aspects)))
(branch-number (modulo cycle-year (length terrestrial-branches)))
(element (list-ref elements element-number))
(zodiac-animal (list-ref zodiac-animals branch-number))
(aspect (list-ref aspects aspect-number)))
(let-values (([stem-han stem-pinyin] (han/pinyin-nth stem-number celestial-stems))
([branch-han branch-pinyin] (han/pinyin-nth branch-number terrestrial-branches)))
(list ce-year stem-han branch-han stem-pinyin branch-pinyin element zodiac-animal aspect))))
(module+ test
(for ((ce-year (in-list '(1935 1938 1941 1947 1968 1972 1976))))
(apply printf "~a: ~a~a (~a-~a, ~a ~a; ~a)~%" (chinese-zodiac ce-year))))