IF Computer > MINERVA > Manual > Reference > Predicates > Atomic term processing > sub_atom/5

sub_atom/5

MINERVA
ifcomputer logo
f
Expert Services on the Web

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.

document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Predicates/atomic_term/sub_atom/print_de.html
published 2008/11/17 update 2003/7/8 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 start (AT) ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
Back> managed with ubiCMS