Did you know ... Search Documentation:
Pack onepointfour_basics -- prolog/stringy_morph.pl
PublicShow source

This code is specific to SWI-Prolog, as that Prolog provides the traditional "atom" and the non-traditional "string" as two distinct representations of "sequences of characters".

We introduce the following additional vocabulary:

  • A stringy term is a term that is either an atom or a string. In SWI-Prolog, the string is a distinct representation of a sequence of characters, distinct from the atom and mean to be used in text processing rather than as basis for identifiers.
  • A chary term is a term that is either a char (an atom of length 1) or a code (an integer and, more precisely in SWI-Prolog, a Unicode code point).
  • A charylist is less precise: it is a proper list of either codes or chars. It may or may not contain uninstantiated elements. An empty list is a charylist but we cannot know whether it is supposed to be composed of codes or chars. A list containing only uninstantiated variables is also a charylist and again we don't know what it is supposed to contain, at least not yet.

Homepage for this code

https://github.com/dtonhofer/prolog_code/blob/main/unpacked/onepointfour_basics/README_stringy_morph.md

History

  • 2021-01-19: Reviewed
  • 2021-02-16: Reviewed for packs, updated to pldoc.
  • 2021-02-17: Trashed all the old code for testing "stringyness" and wrote new one based on the "texty type tree"
  • 2021-06-11: Back up on github
 stringy_morph(?StringyA, ?StringyB, ?TypeA, ?TypeB)
Behaves leniently, i.e. preferably fails instead of throwing if bad values are passed.
 stringy_morph(?StringyA, ?StringyB, ?TypeA, ?TypeB, @Tuned)
Establish the "morph" relationship between StringyA (an atom or a string) and StringyB (an atom or a string) whereby
  • StringyA and StringyB hold the same character sequence, and
  • the actual type of StringyA is given by TypeA, and
  • the actual type of StringyB is given by TypeB Actual values of TypeA and TypeB are one of atom or string.

    Generate multiple solutions as possible.

    Tuned is input only. If it is bound to hard, unwanted argument combinations lead to exception. If is bound to soft (actually, anything other than hard. unwanted argument combinations lead to failure.

 stringy_charylist_morph(Stringy, Charylist, StatedStringyType, StatedCharylistType)
 stringy_charylist_morph(Stringy, Charylist, WantStringy, WantCharylist)
Map a stringy to a charylist.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 stringy_charylist_morph(Arg1, Arg2, Arg3, Arg4, Arg5)