Found in 1 comment on Hacker News
GregBuchholz · 2016-06-21 · Original thread
It is hard to beat using Prolog for whipping out interpreters. Like Lisp, you get to use symbols in terms, plus you also get to use Prolog's ability to use infix operators to create terms:

    eval(X,X) :- number(X).
    eval(X+Y,Z) :- eval(X,X1), eval(Y,Y1), Z is X1+Y1.
    eval(X*Y,Z) :- eval(X,X1), eval(Y,Y1), Z is X1*Y1.
    
    main :- write("Enter an arithmetic expression followed by a dot \".\" and a newline\n"),
            prompt(_Old,>),
            repl.

    repl :- read(Input),
            eval(Input,Answer),
            print(Answer), nl,
            repl.

You might like:

https://www.metalevel.at/lisprolog/

http://www.swi-prolog.org/

https://www.amazon.com/Art-Prolog-Advanced-Programming-Techn...

Fresh book recommendations delivered straight to your inbox every Thursday.