- The cambridge site linked from TFA appears to be hugged-to-death, but I found something that appears to be the same code, under an apache license[1]
I modified that to work under SBCL (but with style-warnings), and fixed up the first example from TFA to actually be free of style-warnings even under sbcl[2]
NB: The code from the book is exceedingly non-idiomatic lisp. In addition, many of the constants violate the (rather strict) ANSI rules around defining constants, so I worked around that by making them special variables (i.e. s/defconstant/defparameter/). A lot could be done to clean things up and allow faster calculations, but finding all ramadan/ash-wednesday correlations in a 5000 (not a typo 10x what TFA does) takes under 1ms on my machine, so shrug
The code from TFA is much, much worse than the code in calendar.l, but there was less of it so I could fix it up a bit more.
1: https://github.com/EdReingold/calendar-code2/blob/main/calen...
2: https://gist.github.com/jasom/1338543679a596449c324eddf716cc...
- >The code from the book is exceedingly non-idiomatic lisp.
*twitch* You weren't kidding. I'd be tempted to rewrite it if I thought anyone would use it.(defconstant true t)- You and me both (though I'm also annoyed by the overuse of macros instead of inline functions and the woeful lack of docstrings and type declarations).
- Well most of the local bindings are a single letter, so we gotta make sure booleans stand out!
- They probably want to replace the header of calendar.l with something roughly like:
Note that :acre could also be 'acre or #:acre or "ACRE"; any string-designator[1] will do. If there are really a few hundred of them then #:acre or "ACRE" has advantages (the other two ways intern symbols).(defpackage "CC4" (:use "COMMON-LISP") (:export :acre :advent :akan-day-name :akan-day-name-on-or-before [and so on for a few hundred lines] :yom-ha-zikkaron :yom-kippur :zone )) (in-package "CC4")> believe the problem with the unedited code has something to do with packages and namespaces
Since "package" is what Common Lisp calls namespaces, the "and namespaces' is redundant, but the general thrust is correct.
1: https://www.lispworks.com/documentation/HyperSpec/Body/26_gl...