logoalt Hacker News

zahlmanlast Thursday at 5:10 AM1 replyview on HN

Prolog admittedly mystifies me even more than the Haskell family. How do you do anything effectful, like read from a file, or output arbitrary data to standard out, or set up a loop to process keyboard events every 1/n seconds? How do you make system calls?


Replies

pjmlplast Thursday at 1:20 PM

By thinking in LP terms, like FP, LP requires rewiring the brain to think differently how to approach algorithms.

Here is a sample on how to read a file.

https://lpn.swi-prolog.org/lpnpage.php?pagetype=html&pageid=...

How to make syscalls,

https://www.swi-prolog.org/pldoc/man?section=foreign