| unifies by backtracing one atom with all substrings of another atom.
sub_atom(+Atom, ?LeftLength, ?Length, ?RightLength, ?SubAtom)
sub_atom/5 unifies by backtracking SubAtom with all substrings
of Atom where
Length is the length of SubAtom,
LeftLength is the length of the substring of Atom on the
left side of SubAtom and
RightLength is the length of the substring of Atom on the
right side of SubAtom.
Arguments
Atom atom
LeftLength integer or an expression with substitution integer
Length integer or an expression with substitution integer
RightLength integer or an expression with substitution integer
SubAtom atom
Examples
| sub_atom(text, LL, 3, RL, S). |
Succeeds with substitutions
{LL <- 0, RL <- 2, S <- 'te'}
{LL <- 1, RL <- 1, S <- 'ex'}
{LL <- 2, RL <- 0, S <- 'xt'} |
| sub_atom(abcabd, LL, 2, RL, ab). |
Succeeds with substitutions
{LL <- 0, RL <- 4}
{LL <- 3, RL <- 1} |
| sub_atom(hello, 0, 3, _, Prefix). |
Succeeds with substitution
{Prefix <- hel}
|
| sub_atom(hello, _, 3, 0, Suffix). |
Succeeds with substitution
{Suffix <- llo}
|
| sub_atom(hello, 1, 3, _, Infix). |
Succeeds with substitution
{Infix <- ell}
|
Standard
This predicate is part of the ISO-Prolog Standard.
See also
atom_chars/2,
atom_codes/2,
atom_concat/3,
atom_length/2,
atom_number/2,
char_code/2,
number_chars/2,
number_codes/2,
parse_atom/2/3.
|