←back to thread

Learn Prolog Now

(lpn.swi-prolog.org)
226 points rramadass | 1 comments | | HN request time: 0.199s | source
Show context
zemptime ◴[] No.45902006[source]
I've recently started modeling some of my domains/potential code designs in Prolog. I'm not that advanced. I don't really know Prolog that well. But even just using a couple basic prolog patterns to implement a working spec in the 'prolog way' is *unbelievably* useful for shipping really clean code designs to replace hoary old chestnut code. (prolog -> ruby)
replies(2): >>45902088 #>>45907483 #
ramses0 ◴[] No.45902088[source]
I keep wishing for "regex for prolog", ie: being able to (in an arbitrary language) express some functional bits in "prolog-ish", and then be able to ask/query against it.

    let prologBlob = new ProLog()
    prologBlob.add( "a => b" ).add( "b => c" )
    prologBlob.query( "a == c?" ) == True
(not exactly that, but hopefully you get the gist)

There's so much stuff regarding constraints, access control, relationship queries that could be expressed "simply" in prolog and being able to extract out those interior buts for further use in your more traditional programming language would be really helpful! (...at least in my imagination ;-)

replies(7): >>45902466 #>>45902575 #>>45902589 #>>45902735 #>>45903753 #>>45904363 #>>45904569 #
1. jll29 ◴[] No.45904363[source]
What you mean is not "regex for Prolog" but an embedded PROLOG interpreter, which exists.

Ironically, the most common way I have seen people do this is use an embedded LISP interpreter, in which a small PROLOG is easily implemented.

https://www.metalevel.at/lisprolog/ suggests Lisprolog (Here are some embedded LISPs: ECL, PicoLisp, tulisp)

SWI-Prolog can also be linked against C/C++ code: https://stackoverflow.com/questions/65118493/is-there-any-re... https://sourceforge.net/p/gprolog/code/ci/457f7b447c2b9e90a0...

Racklog is an embedded PROLOG for Racket (Scheme): https://docs.racket-lang.org/racklog/