B u s L o g i c:- prolog, code, chatter.

Purity: A Horn Clause Only library for Prolog

Up: Purity

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.

Standalone version

To use the standalone version of Purity, download the purity.pl file and add the following to your program:

:- include('purity.pl').

If the system does not support include, then you can consult manually using:

?- ['purity.pl'].

or ..

?- consult('purity.pl').

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.

SWI-Prolog Package

  1. Install the purity pack, following the instructions.

    ?- pack_install(purity).
  2. Set the prolog flag to allow double quotes to become chars.

    ?- set_prolog_flag(double_quotes, chars).
  3. Include the purity librarys in the code.

    ?- use_module(library(pstring)).
    ?- use_module(library(plist)).
  4. Write a query

    ?- assert((
        purity_test(S, R) :- 
            pstr_split(S, ' ', Split), 
            pexclude((eq(pstring, "is"), Split, Small),
            pstr_join(Small, '-', R)
    ?-   purity_test("This is a test", R),  maplist(write, R), nl.
    R = ['T', h, i, s, -, a, -, t, e|...].

Ready for action.