Did you know ... Search Documentation:
Pack onepointfour_basics -- prolog/README.md

Some basic predicates that seem useful

General structure

This directory contains several SWI-Prolog module files (ending in .pl) and their associate unit test files (ending in.plt), which contain one or more plunit modules.

The module files are relatively "small" and provide specific functionality. We avoid large modules where in-module interrelationships are hard to survey.

In this picture, the links from checks.pl to the other modules are not shown. The orange modules are the "big collectors" of submodules. Modules in the grey boxes (subdirectories) provide service exclusively to their repsective orange "collecting" modules.


Loading a module and running its tests (in SWI-Prolog)

Put the directory just above this package directory onto the list of library directories. This can be done with the following directive (or command), where you shall replace `/foo/bar` with the correct path for your machine:

:- assertz(file_search_path(library,'/foo/bar/prolog_code/unpacked')).

After that:

  • Load the module by relative filename, with use_module/1.
  • Load the accompanying `.plt` file with load_test_files/1.
  • Run the detected plunit tests with run_tests/0. For example, for the module defined in file space_string.pl (note that SWI-Prolog loads module files by filename not by module name, although the module name is important):
    ?- use_module(library('onepointfour_basics/space_string.pl')).
    ?- load_test_files([]).
    ?- run_tests.

    The bin directory contains a shell script which runs all the test.

Module naming

The name of a module is relatively arbitrary. We always use the atom onepointfour_basis_X where X is the suffix-less name of the file in which the module is defined.

License information

Major elements


A more powerful replacement for the venerable must_be/2. The predicates provided by checks.pl are used throughout other code.



An SWI-Prolog dict prettyprinter.


Minor elements


A "logical" mapper between atoms and SWI-Prolog strings and "list representations" of character sequences, i.e. "proper lists of char" and "proper lists of code". Provides replacement for the predicates atom_string/2, atom_codes/2, string_chars/2, string_codes/2.



Create or accept atoms or strings made only of the SPACE character (Unicode code point 0x20).



Analysis of "stringy" (atom or string) and "chary" (lists of chars or codes) terms.



Concantenate several "stringy" terms (atoms or strings) to a single "stringy" term. A front-end to the corresponding SWI-Prolog predicates.



Determine the length of a "stringy" term (atom or string).



Justify text left, right or center in a field of a given width. This is an ingredient of the dict prettyprinter.



Overwrite background text with foreground text. This is an ingredient of the dict prettyprinter.



A simple predicate fronting format/3, but able to survive a mistake in the number or type of arguments without throwing. Strongly useful in any code which may not have been given 100% coverage.

doc/README_safe_format.md (README TO BE DONE)


Various meta-predicate meant to make code writing and especially reading easier.

doc/README_meta_helpers.md (README TO BE DONE)


A very small set of predicates that are meant to use a dict as an options container, possibly providing defaults for missing options.

doc/README_dict_settings.md (README TO BE DONE)