3 ms·
I tried to run this on my computer now, but as a complete Prolog noob, I'm having errors running the script? How do you load the http_open module/library in the
by pandatigox 5y ago
I tried to run this on my computer now, but as a complete Prolog noob, I'm having errors running the script? How do you load the http_open module/library in the first place? I tried following some Prolog tutorials in the past but I always get stuck trying to run something in the REPL. I'm using scryer-prolog. Thanks in advance!
- triska 5y agoThe libraries I mentioned can be loaded by invoking the use_module/1 predicate on the toplevel, here is the complete transcript that loads the SGML, HTTP and XPath libraries in Scryer Prolog: ?- use_module(library(sgml)). true. ?- use_module(library(http/http_open)). true. ?- use_module(library(xpath)). true. The second query also uses portray_clause/1 from library(format), which you can load with: ?- use_module(library(format)). true. After all these libraries are loaded, you can post the sample queries from above, and it should work. There are also other ways to load these libraries: A very common way to load a library is to use the use_module/1 directive in Prolog source files. In that case, you would put for example the following 4 directives in a Prolog source file, say sample.pl: :- use_module(library(sgml)). :- use_module(library(http/http_open)). :- use_module(library(xpath)). :- use_module(library(format)). And then run sample.pl with: $ scryer-prolog sample.pl You can then again post the goals from above on the toplevel, and it will work too. Another way is to put these directives in your ~/.scryerrc configuration file, which is automatically consulted when Scryer Prolog starts. I recommend to do this for libraries you frequently need. Common candidates for this are for example library(dcgs), library(lists) and library(reif). Personally, I start Scryer Prolog from within Emacs, and I have set up Emacs so that I can consult a buffer with Prolog code, and also post queries and interact with the Prolog toplevel from within Emacs.
- pandatigox 5y agoWow that works fantastically! Thank you for that. It almost seems like magic.