Purity: A Horn Clause Only library for Prolog
Purity Quick Start
There are two versions of Purity, a standalone version that contains no module information and a package that can be installed using SWI-Prolog.
To use the standalone version of Purity, download the purity.pl file and add the following to your program:
If the system does not support include, then you can consult manually using:
The prolog system should convert string encased in double quotes to a list of characters eg:
?- X = "test". X = [t,e,s,t].
If not then the default way to change this is to set a prolog flag.
Install the purity pack, following the instructions.
Set the prolog flag to allow double quotes to become chars.
?- set_prolog_flag(double_quotes, chars).
Include the purity librarys in the code.
?- use_module(library(pstring)). ?- use_module(library(plist)).
Write a query
?- assert(( purity_test(S, R) :- pstr_split(S, ' ', Split), pexclude((eq(pstring, "is"), Split, Small), pstr_join(Small, '-', R) )). true. ?- purity_test("This is a test", R), maplist(write, R), nl. This-a-test R = ['T', h, i, s, -, a, -, t, e|...].
Ready for action.