3/21/2026 at 3:48:10 AM
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...
by aidenn0
3/21/2026 at 9:05:32 AM
>The code from the book is exceedingly non-idiomatic lisp. (defconstant true t)
*twitch* You weren't kidding. I'd be tempted to rewrite it if I thought anyone would use it.
by shawn_w
3/21/2026 at 7:04:40 PM
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).by tmtvl
3/21/2026 at 8:40:23 PM
Yeah, there's a lot of comments that should be docstrings.And lots of lists that should be structures or classes...
by shawn_w
3/21/2026 at 8:47:42 PM
Macros instead of inline functions is just archaic, not necessarily non-idiomatic. I'm not sure when inline declarations were added, but even well after that point macros were more reliable for getting inlining.by aidenn0
3/22/2026 at 1:56:16 PM
Calendrica has been around for that long already? How time flies. Was also interesting to find an off-by-1 bug in final (if the condition doesn't hold for initial the result is smaller than initial instead of greater than or equal to it). Interesting little program to read, though.by tmtvl
3/21/2026 at 4:15:09 PM
Well most of the local bindings are a single letter, so we gotta make sure booleans stand out!by aidenn0