pack(options)


A stoics.infrastructure prolog pack

This is a stoics infrastructure pack for SWI-Prolog that deals with predicate options. The main concept is to treat options as naive Prolog lists which the programmer can manipulate and specialise if they need to, while providing a number of basic predicates that manage basic common operations on options. Options are particularly important in the context of SWI packs, as making code publicly available to others often involves allowing for variations in the behaviour of the code.

installation

In SWI It is highly recommended that you install from within by using its package manager.
To install simply do:

 

   ?- pack_install(options).

   And then load by:

   ?- use_module( library(options) ).

   To test 

   ?- [pack(options/examples/ex_sort)].

   ?- ex_sort( [a,b,e,c,b], Ord, true ).
   Ord = [a, b, c, e].
   ?- ex_sort( [a,b,e,c,b], Ord, debug(true) ).
   % Input list length: 5
   % Output list length: 4
   Ord = [a, b, c, e].
   ?- ex_sort( [a,b,e,c,b], Ord, order(>) ).
   Ord = [e, c, b, a].
   ?- ex_sort( [a,b,e,c,b], Ord, duplicates(true) ).
   Ord = [a, b, b, c, e].
   
   Create file $HOME/.pl/ex_sort.pl with content
   order(>). 

   ?- ex_sort( [a,b,e,c,b], Ord, true ). 
Ord = [e, c, b, a]. Default for user is now order(>) which can still be over-ridden at invocation
?- ex_sort( [a,b,e,c,b], Ord, order(<) ). Ord = [a, b, c, e].

materials

module documentation: options.html
sources: options
github: stoics.infra

author

Nicos Angelopoulos
---
London
July, 2015 - March 2018