2 ms·
> Convenient and efficient text processing was the original goal of Prolog That was actually where I first saw "real" Prolog program: in University in the intr
by Tomte 4y ago
> Convenient and efficient text processing was the original goal of Prolog
That was actually where I first saw "real" Prolog program: in University in the introduction to computational linguistics lecture.
Parsing syntax trees, annotating trees with semantic meaning, and calculating all kinds of cool stuff I don't remember anymore was eye-opening.
Unfortunately, our lecturer used IBM Prolog, we students had only access to SWI, and none of his programs worked on SWI.
That made the lecture very frustrating, and doubly so, because the lecturer all those years before our cohort was excellent, with great study material and exercises.
- triska 4y agoThese use cases become especially interesting now with several recent Prolog systems such as Scryer, Tau, Trealla and ichiban/prolog: All these systems set the Prolog flag double_quotes to chars already by default, and this means that we can write lists of characters especially conveniently as double-quoted strings in programs in queries! For example, the list of characters [a,b,c] can be conveniently written as "abc" in all these systems, and of course also if we manually set the flag to chars in any conforming Prolog system. Scryer and Trealla combine this default for the flag with an extremely efficient internal representation of strings, using packed UTF-8 encoding internally, so that also very large amounts of text can be efficiently and conveniently processed with DCGs. In Trealla Prolog, using phrase_from_file/2 even transparently maps the file contents to memory with the system call mmap(2) for extreme performance.