11.3.213 sub_atom/5 [ISO]

Synopsis

sub_atom(+Atom,-Before,-Length,-After,-SubAtom)

The characters of SubAtom form a sublist of the characters of Atom, such that the number of characters preceding SubAtom is Before, the number of characters after SubAtom is After, and the length of SubAtom is Length.

Arguments

Atom
atom, must be nonvar

The atom from which a part is selected.

Before
integer

The number of characters preceding SubAtom.

Length
integer

The number of characters of SubAtom.

After
integer

The number of characters following SubAtom.

SubAtom
atom

The selected part of Atom.

Description

Capable of nondeterminately enumerating all sub-atoms and their all possible placements, e.g.:

     | ?- sub_atom(abrakadabra, Before, _, After, ab).
     
     After = 9,
     Before = 0 ? ;
     
     After = 2,
     Before = 7 ? ;
     
     no

Exceptions

instantiation_error
Atom is uninstantiated.
type_error
Atom is not an atom. Before, Length, or After, if instantiated, is not an integer. SubAtom, if instantiated, is not an atom.
domain_error
Before, Length, or After, if instantiated, is negative.

See Also

atom_length/2, atom_concat/3.


Send feedback on this subject.