Data update

This commit is contained in:
Ingy döt Net 2024-07-13 15:19:22 -07:00
parent 29a5eea0d4
commit 5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions

View file

@ -0,0 +1,36 @@
(defun abbreviate-list (list-of-days abbreviation-length)
"Take each element of LIST-OF-DAYS and abbreviate to ABBREVIATION-LENGTH."
(let ((abbrev-list)
(abbrev-element))
(dolist (one-element list-of-days) ; loop through each day of week
;; if the day of week is at least as long as the abbreviation
(if (>= (length one-element) abbreviation-length) ; if day >= abbreviation length
(setq abbrev-element (substring one-element 0 abbreviation-length)) ; abbreviate the day of the week
(setq abbrev-element one-element)) ; otherwise don't abbreviate
(push abbrev-element abbrev-list)) ; put the abbreviated/non-abbreviated day on our list
abbrev-list)) ; return the list of abbreviated days
(defun cycle-days (list-of-days)
"Find shortest unique abbreviation in LIST-OF-DAYS list."
(let ((abbrev-list)
(abbrev-length 1)
(current-abbrev)
(looking-for-shortest-list t))
(if (= (length list-of-days) 0) ; if list-of-days is empty (i.e., blank line)
(setq looking-for-shortest-list nil)) ; then don't look for the shortest unique abbreviations
(while looking-for-shortest-list ; as long as we are looking for the shortest unique abbreviations
(setq abbrev-list (abbreviate-list list-of-days abbrev-length)) ; get a list of abbreviated day names
(if (= (length list-of-days) (length (seq-uniq abbrev-list))) ; if abbreviated list has no duplicates
(progn
(message (format "%d %s" abbrev-length list-of-days)) ; then in echo buffer show length and days
(setq looking-for-shortest-list nil)) ; also, then don't look for the shortest unique abbreviations
(setq abbrev-length (+ abbrev-length 1)))))) ; else increase the length of the abbreviation; loop to while
(defun days-of-week ()
"Find minimum abbreviation length of days of week."
(let ((current-line-list))
(find-file "Days_of_week.txt") ; open file or switch to buffer
(beginning-of-buffer) ; go to the top of the buffer
(dolist (current-line (split-string (buffer-string) "\n")) ; go line by line through buffer
(setq current-line-list (split-string current-line " ")) ; change each line into list of days of week
(cycle-days current-line-list))))

View file

@ -0,0 +1,17 @@
# Experimental!
# Find shortest distinct abbreviation length per line
Lines ← {"Sunday Monday Tuesday Wednesday Thursday Friday Saturday"
"sing_kei_yaht sing_kei_yat sing_kei_yee sing_kei_saam sing_kei_sie sing_kei_ng sing_kei_luk"
""
"Diu_prima Diu_sequima Diu_tritima Diu_quartima Diu_quintima Diu_sextima Diu_sabbata"
"sunnudagur mánadagur tÿsdaguy mikudagur hósdagur friggjadagur leygardagur"
"Yek_Sham'beh Do_Sham'beh Seh_Sham'beh Cha'har_Sham'beh Panj_Sham'beh Jom'eh Sham'beh"}
# Return 1+max_common_prefix
AbbrevLen ← +1/↥◹(/↥↘1)⊞(/+\↧⬚@ =∩°□).
Split ← ⊜□⊸(≠@ )
RemoveEmpty ← ▽⊸(≡(≠0◇⧻))
Line ← ⊂⊂:": " °⋕:⊸(/(⊂⊂) " "≡(⬚@ ↙:°□)⊙¤)⟜AbbrevLen ◇Split
≡⍚Line RemoveEmpty Lines
≡&p