New pack "options" available on the server.
This is a stoics.infrastructure pack for handling option arguments.
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
small number of predicates that manage basic common operations on options.
Options come into their own in the context of SWI packs, as making
code publicly available to others often involves allowing for variations
in the behaviour of the code.
Some distinctive features of pack(options)
* minimal "magic" behind the scenes
* processing debug(Dbg) terms which optionise calls to debug/1
* allows sloppy (un-listed) single option argument (en_list/2)
* defaults might depend on input
* can-do cascading (options of distinct predicates should be disjoint)
* uniform access to user specific file-based defaults
Comes with a simple example,
?- [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].
?- ex_sort( [a,b,e,c,b], Ord, [duplicates(true),order(>)] ).
Ord = [e, c, b, b, a].
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].
more info:
http://stoics.org.uk/~nicos/sware/options---
Nicos Angelopoulos
http://stoics.org.uk/~nicos