Synopsis

:- use_module(library(sweet)).

?- (false -> throw(oops); otherwise -> writeln(ok)).
ok
true.

?- if(fail,throw(oops)), if(true,writeln(ok)).
ok
true.

?- forall(X in [1,2,3], writeln(ok)).
ok
ok
ok
true.

:- use lists -> append/{2,3}, last/2.
% same as use_module(library(lists),[append/2,append/3,last/2]).

Description

The sweet pack adds some convenient syntactic sugar to Prolog. The main goal is to reduce the amount of redundant code that one must read (and write). Some of the predicates and macros are simple aesthetic adjustments (like otherwise/0). Others, like in/2, define powerful interfaces which can be extended by library authors.

Changes in this Version

Installation

Using SWI-Prolog 6.3 or later:

?- pack_install(sweet).

This module uses semantic versioning.

Source code available and pull requests accepted at http://github.com/mndrix/sweet

author
- Michael Hendricks <michael@ndrix.org>
license
- unlicense

Prolog files

sweet.pl
cleanup/1Sugar for call_cleanup/2.
if/2Same as (Condition->Action;true).
if/3Same as (Condition->Action;Else).
in/2True if X is contained in Xs.
otherwise/0AKA true.
todo/0Throws the exception todo.
todo/1Like todo/0 with a Note.
todo/2Like todo/1 but provides space for something Extra.
use/1Macros for importing modules.