Home | Zones | Log in | Register

prolog pals

learning logic power prolog

Nobody
 ⬇︎ 
Page 1 of /1

i’ve been integrating biscuits (https://www.clever-cloud.com/blog/engineering/2021/04/15/biscuit-tutorial/) into some of the stuff i do and i find its usage of datalog for authz stuff very cool
so i decided to learn prolog 4 real

i have two goals

  • integrate this with something https://github.com/ichiban/prolog perhaps using it for game AI?
  • solve the bin packing problem cuz its what my job uses for its take-home test

second goal is way easier so working towards that first
currently reading thru this tutorial series
The Power of Prolog
https://www.metalevel.at/prolog

(copy/pasted from the other blue websight)

i got thru some of it and successfully did that water pouring puzzle following the nice teacher’s instructions
then i tried to implement bin packing and failed miserably

still dont really understand how phrase() etc works but it seems hella useful
starting to “Think In States” a bit more

Manual tag

Trying too hard

What Prolog implementation are you using, Tiko? I’m torn between gprolog and swi-prolog.

Edited by MasterOfMagic at 2022-01-20 00:08:422022-01-20 00:08
Trying too hard

From: MasterOfMagic at 2022-01-20 00:07:55
What Prolog implementation are you using, Tiko? I’m torn between gprolog and swi-prolog.

i’ve been using SWISH which is the online version of swi
https://swish.swi-prolog.org/example/examples.swinb

i tried setting up scryer or w/e the fancy new rust one is but i’m too lazy to Install Rust
and the GUI version of SWI confuses me
the web one is ezpz tho

lmk if gprolog is any good 👀

Will do. I’m in the process of setting up Emacs with it since I’ve really been digging SLIME for Common Lisp and ELPA for Python.

Trying too hard

GNU prolog crashes with a segfault if I break execution and choose abort, break, or exit, so that’s it for that.

Trying too hard

i’ve been screwing around with implementing multiplayer prolog over slack
aka a slack bot

i have one i used that executes shell commands and replies with the stdout, so i’m repurposing that idea but with prolog

i added some slack-specific predicates like channel_name/2 and say/3 as well as a dynamic predicate im calling env that has info related to the message that triggered it

for example

pikesay(To, Msg) :-
  say(To, Msg, [emoji(pike), name('Rob Pike')]),
  !.

pikesay(Msg) :-
  env(channel, To),
  pikesay(To, Msg).

2022-01-30 (2).png

and you can use op/3 to define #/1 and @/1 to handle channel and user references

2022-01-30 (1).png

i still have so much to learn but this is fun

i’m trying to figure out persistence next
prolog owns

o yeah i used the go interpreter, ichiban/prolog
and added ‘native’ predicates for some slack specific stuff

Reply:
To reply to this thread, please join this community.
Pages: 1
1 person is reading this thread now.
Thread List | ↑ Top