Did you know ... | Search Documentation: |
![]() | Packs (add-ons) for SWI-Prolog |
Title: | Relational predicate accessors generators that allow easy and efficient access to term arguments by name. |
---|---|
Rating: | Not rated. Create the first rating! |
Latest version: | 1.1.2 |
SHA1 sum: | bb45d6bdc0ca9ffb449bcb315a993a0c7de9a00f |
Author: | Luiz Fernando https://github.com/LuizFBR |
Maintainer: | Luiz Fernando https://github.com/LuizFBR |
Packager: | Luiz Fernando https://github.com/LuizFBR |
Home page: | https://github.com/LuizFBR/accessors |
Download URL: | https://github.com/LuizFBR/accessors.git |
No reviews. Create the first review!.
Version | SHA1 | #Downloads | URL |
---|---|---|---|
1.1.2 | bb45d6bdc0ca9ffb449bcb315a993a0c7de9a00f | 2 | https://github.com/LuizFBR/accessors.git |
1.0.1 | 00bb08757620ad9ba8d39c2494d4138dfd72edd8 | 2 | https://github.com/LuizFBR/accessors.git |
1.0.0 | 3f103c09002fb2d7770e1a12f36f059b172d9a7f | 1 | https://github.com/LuizFBR/accessors.git |
Relational predicate accessors generators that allows easy and efficient access to term and pairs-lists arguments by name.
This library provides the user with the :- derive_accessors/1
and :- derive_accessors/2
prolog directives that automatically generate relational predicates that associate a predicate/pairs-list with each of its arguments.
The choice of imperative naming for :- derive_accessors
was to keep this library user-friendly for users who are used to imperative programming.
To-do:
To install the fld library, type the following in the SWI-Prolog shell:
? - pack_install('accessors'). true.
or, alternatively, you can install directly from this github repo:
?- pack_install('https://github.com/LuizFBR/accessors.git'). true.
The directive call:
:- derive_accessors(pred(a,b,c)).
will generate the following static predicate accessors globally:
pred_a(pred(A,_,_),A). pred_b(pred(_,B,_),B). pred_c(pred(_,_,C),C).
The directive call:
:- derive_accessors(pred, [a,b,c]).
will generate the following static pairs-list accessors at compile-time:
fact_a(_ListPair,_a) :- member(a-_a,_ListPair). fact_b(_ListPair,_b) :- member(b-_b,_ListPair). fact_c(_ListPair,_c) :- member(c-_c,_ListPair).
Import this module with
:- use_module(library(accessors)).
This library depends on Markus Triskas' clpfd library:
https://www.swi-prolog.org/man/clpfd.html
Pack contains 4 files holding a total of 5.2K bytes.