Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "fnotation"

Title:Function notation for Prolog
Rating:Not rated. Create the first rating!
Latest version:1.0.0
SHA1 sum:35919e0d8d0bd8564aecdf9c439d213d5b3fd3ef
Author:Vitaliy Akimov <vitaliy.akimov@gmail.com>
Maintainer:Vitaliy Akimov <vitaliy.akimov@gmail.com>
Packager:Vitaliy Akimov <vitaliy.akimov@gmail.com>
Home page:https://github.com/awto/fnotation
Download URL:https://github.com/awto/fnotation/archive/v1.0.0.zip

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
0.0.16d6a90c8126b5b21fd1e2d02b9b73f445c21a98b1https://github.com/awto/fnotation/archive/v0.0.1.zip
0.0.2616548027a1f8c7160e9985bf26e3fbf9e296bb42https://github.com/awto/fnotation/archive/v0.0.2.zip
0.0.3282594135f31b9586df083f3c8f7148d09bd19861https://github.com/koo5/fnotation.git
5134ec5a7e127361ebd2467adf7e0169d31e7c8e28https://github.com/awto/fnotation/archive/v0.0.3.zip
b4f3403f46eaa4fe8552365a145e3f309ebae61918https://github.com/koo5/fnotation.git
1.0.035919e0d8d0bd8564aecdf9c439d213d5b3fd3ef2https://github.com/awto/fnotation/archive/v1.0.0.zip

Function notation for Prolog

This is simple term_expansion/2 based macros for functions notation.

This is a simple transform, the output is still easy to debug, it doesn't require special notation for function's definitions, any predicate may be used as a funciton already.

The simpliest usage is for predicate with the only output argument in the last position. But any predicate with any position of output arguments and any number of them may be called as a function. In case of more than one arguments only one can be specified by placeholder but the others may still be bound with some named variable.

Use $> and $< operators in subterms of head or body to specify function's term and its output variable placeholder respectively. If the variable placeholder isn't specified the library will add another (last) argument for the term and use it as an output variable.

e.g.

h1(A, $> h2()) :- p1(A, $> p2($> p3($<, A))) .

and

h1(A, $> h2($<)) :- p1(A, $> p2($> p3($<, A), $<)) .

is converted into:

h1(A,V1) :- h2(V1), p3(V0, A), p2(V0, V2), p1(A, V2) .

The operators names may be changed, for example making both of them to be $$:

:- fnotation_ops($$,$$) .
:- op(900,fx,$$) .

h1(A,R) :- p1($$ p2($$, A), R) .

Contents of pack "fnotation"

Pack contains 5 files holding a total of 6.5K bytes.