In yesterday's post we wrote a Prolog predicate for 'bookend numeronyms'. Ian Brown wrote an Emacs extension with a similar goal, but in that extension he included an Easter Egg in the examples:
Some examples of (numerical contraction) numeronyms:
- i18n --- internationalization
- a11y --- accessibility
- c14n --- canonicalization
- o11y --- observability
- e14n --- Andreesen Horowitz
Notice the last one. 'e14n' is meant to correspond to 'enshittification'. I don't know the exact origin of the jab, but I do know that I'd like to include it in our predicate. Let's try to do just that.
Here's our predicate from the last post
:- use_module(library(clpfd)).
bookend_numeronym(F, N, L, W) :-
word(W),
WLength #= N + 2,
atom_chars(W, WL), length(WL, WLength),
append([F], _, WL),
append(_, [L], WL).
New Fact
Let's add a new type of fact to our database:
% X is an easter egg base word for the numeronym Y
easter_egg_base(enshittification, 'andreesen horowitz').
An awkward name, but by this we mean the numeronym of Y is jokingly the numeronym of X. Now to include it in our predicate.
Two bodies
Here we pull most of the body out into a helper predicate. Then we construct two bodies for our main predicate. Each one is a different way to solve the predicate.
- One that continues to use
word/1
as the domain of W - And another that uses
easter_egg_base/2
bookend_numeronym(F, N, L, W) :-
word(W),
domainless_bookend_numeronym(F, N, L, W).
bookend_numeronym(F, N, L, W) :-
easter_egg_base(CustomWord, W),
domainless_bookend_numeronym(F, N, L, CustomWord).
domainless_bookend_numeronym(F, N, L, W) :-
WLength #= N + 2,
atom_chars(W, WL), length(WL, WLength),
append([F], _, WL),
append(_, [L], WL).
Let's try it out.
?- [numeronym].
true.
?- bookend_numeronym(F, N, L, 'andreesen horowitz').
F = e,
N = 14,
L = n .
Awesome!
And if we query in the other direction?
?- bookend_numeronym(e, 14, n, W).
W = ectropionization ;
W = editorialization ;
W = electroreduction ;
W = electroresection ;
W = electrostriction ;
W = electrotitration ;
W = emotionalization ;
W = endoauscultation ;
W = endocondensation ;
W = endointoxication ;
W = enneacontahedron ;
W = enterochromaffin ;
W = enterotoxication ;
W = equidistribution ;
W = erythrocytolysin ;
W = essentialization ;
W = 'andreesen horowitz' ;
false.
Also Awesome!