News for hackers. Stuff that matters.
Re:The Power of Prolog by carapace on Thursday April 09, 2020 @03:00PM (#22825968)
Not at all, that would be awesome. It's GPL'd, have at it. (^_^)

I typically use SWI Prolog but I hope the code is mostly portable. The parser uses a couple of DCGs from the "basics" lib but I think those are also portable or at least simple to re-implement.

The tricky bit might be the semantics of math (and comparison) ops. I've tried two other sets of semantics, one that attempts to perform math operations (and catch the errors if e.g. an arg is a logic var rather than an int) as you go, and another that just builds expression trees (evaluation is delayed) like so:

    func(+, [int(A), int(B)|S], [int(A + B)|S]).
Just to point out, in SWI Prolog the ints are "BigNums" while in GNU Prolog they're machine words (so modular arithmetic, mod 2^32). You could use Rationals or make up some other semantics. This all gets into Categorical paradigm programming. http://conal.net/papers/compiling-to-categories/ The same (point-free) expression can be used to develop concrete programs over various categories: Hardware circuits, partial evaluation, differentiation, dataflow graphs, and so on.

There are no comments on this comment yet.