YAP 7.1.0
Predicates on Atoms and Strings

The following predicates are used to manipulate atoms, strings, lists of codes and lists of chars. More...

Detailed Description

The following predicates are used to manipulate atoms, strings, lists of codes and lists of chars.


Class Documentation

◆ hide_atom/1

class hide_atom/1

hide_atom(+ Atom)

Make atom Atom invisible, by removing it from the Atom Table

Existing referebces are still active Defining a new atom with the same characters will result in a different atom.xs

◆ hidden_atom/1

class hidden_atom/1

hidden_atom( +Atom )

Is true if the atom Ãtom is not visible to Prolog?

◆ unhide_atom/1

class unhide_atom/1

unhide_atom(+ Atom)

Make hidden atom Atom visible

Note that the operation fails if another atom with name Atom was defined since

◆ char_code/2

class char_code/2

char_code(? A,? I)

defined in the ISO standard

The built-in succeeds with A bound to character represented as an atom, and I bound to the character code represented as an integer At least, one of either A or I must be bound before the call

◆ name/2

class name/2

name( A, L)

The predicate holds when at least one of the arguments is ground (otherwise, an error message will be displayed) The argument A will be unified with an atomic symbol and L with the list of the ASCII codes for the characters of the external representation of A

name(yap,L).
name( A, L)

will return:

L = [121,97,112].

and

name(3,L).

will return:

L = [51].

◆ string_to_atomic/2

class string_to_atomic/2

string_to_atomic(?S, ?Atomic)

Unify from a string S with a number, if S can be parsed as such, or otherwise to an atom

Examples:

◆ atomic_to_string/1

class atomic_to_string/1

atomic_to_string(?Atomic.?String)

◆ string_to_atom/2

class string_to_atom/2

string_to_atom(?String, ?Atom)

◆ atom_to_string/1

class atom_to_string/1

atom_to_string(?Atom.?String)

◆ atom_string/1

class atom_string/1

atom_string(?Atom.?String)

◆ atom_chars/2

class atom_chars/2

atom_chars(? A,? L)

defined in the ISO standard

The predicate holds when at least one of the arguments is ground (otherwise, an error message will be displayed) The argument A must be unifiable with an atom, and the argument L with the list of the characters of A

◆ atom_codes/2

class atom_codes/2

atom_codes(?Atom, ?Codes)

?- atom_codes( a, Cs ).
Cs = [97].
?- atom_codes( `a`, Cs ).
Cs = [97].
no
?- atom_codes( A, "hello" ).
A = hello.
?- atom_codes( 3.3, Cs ).
Cs = [51,46,50,57,57,57,57,57,57,57,57,57,57,57,57,57,57,56].
?- atom_codes( `a`, Cs ).
Cs = [97].
?- atom_codes( 3, [51] ).
yes
?- atom_codes( '3', [51] ).
yes
?- atom_codes( X, [51] ).
X = '3'.

◆ number_chars/2

class number_chars/2

number_chars(? I,? L)

defined in the ISO standard

The predicate holds when at least one of the arguments is ground (otherwise, an error message will be displayed) The argument I must be unifiable with a number, and the argument L with the list of the characters of the external representation of I

◆ number_codes/2

class number_codes/2

number_codes(? I,? L)

The predicate holds when at least one of the arguments is ground (otherwise, an error message will be displayed) The argument I must be unifiable with a number, and the argument L must be unifiable with a list of UNICODE numbers representing the number

◆ number_atom/2

class number_atom/2

number_atom(? I,? A)

The predicate holds when at least one of the arguments is ground (otherwise, an error message will be displayed) The argument I must be unifiable with a number, and the argument A must be unifiable with an atom representing the number

◆ number_string/2

class number_string/2

number_string(? I,? L)

The predicate holds when at least one of the arguments is ground (otherwise, an error message will be displayed) The argument I must be unifiable with a number, and the argument L must be unifiable with a term string representing the number

◆ atom_length/2

class atom_length/2

atom_length(+ A,? I)

defined in the ISO standard

The predicate holds when the first argument is an atom, and the second unifies with the number of characters forming that atom If bound, I must be a non-negative integer

◆ atomic_length/2

class atomic_length/2

atomic_length(+ A,? I)

defined in the ISO standard

The predicate holds when the first argument is a number or atom, and the second unifies with the number of characters needed to represent the number, or atom

◆ downcase_text_to_atom/2

class downcase_text_to_atom/2

downcase_text_to_atom(+Text, -Atom)

Convert all upper case code-points in text Text to downcase Unify the result as atom Atom with the second argument

◆ upcase_text_to_atom/2

class upcase_text_to_atom/2

upcase_text_to_atom(+Text, -Atom)

Convert all lower case code-points in text Text to up case Unify the result as atom Atom with the second argument

◆ downcase_text_to_string/2

class downcase_text_to_string/2

downcase_text_to_string(+Text, -String)

Convert all upper case code-points in text Text to downcase Unify the result as string String with the second argument

◆ upcase_text_to_string/2

class upcase_text_to_string/2

upcase_text_to_string(+Text, -String)

Convert all lower case code-points in text Text to up case Unify the result as string String with the second argument

◆ downcase_text_to_codes/2

class downcase_text_to_codes/2

downcase_text_to_codes(+Text, -Codes)

Convert all upper case code-points in text Text to downcase Unify the result as a sequence of codes Codes with the second argument

◆ upcase_text_to_codes/2

class upcase_text_to_codes/2

upcase_text_to_codes(+Text, -Codes)

Convert all lower case code-points in text Text to up case Unify the result as a sequence of codes Codes with the second argument

◆ downcase_text_to_chars/2

class downcase_text_to_chars/2

downcase_text_to_chars(+Text, -Chars)

Convert all upper case code-points in text Text to downcase Unify the result as a sequence of chars Chars with the second argument

◆ upcase_text_to_chars/2

class upcase_text_to_chars/2

upcase_text_to_chars(+Text, -Chars)

Convert all lower case code-points in text Text to up case Unify the result as a sequence of chars Chars with the second argument

◆ atom_number/2

class atom_number/2

atom_number(? Atom,? Number)

atom_number(? String,? Number)

The predicate holds when at least one of the arguments is ground (otherwise, an error message will be displayed) If the argument Atom is an atom, Number must be the number corresponding to the characters in Atom, otherwise the characters in Atom must encode a number Number

The predicate holds when at least one of the arguments is ground (otherwise, an error message will be displayed) If the argument String is a string term, String must be the number corresponding to the characters in Atom, otherwise the characters in String must encode the number Number

◆ sub_atom/5

class sub_atom/5

sub_atom(+ A,? Bef, ? Size, ? After, ? At_out)

defined in the ISO standard

True when A and At_out are atoms such that the name of At_out has size Size and is a sub-string of the name of A, such that Bef is the number of characters before and After the number of characters afterwards

Note that A must always be known, but At_out can be unbound when calling this built-in If all the arguments for sub_atom/5 but A are unbound, the built-in will backtrack through all possible sub-strings of A

◆ sub_string/5

class sub_string/5

sub_string(+ S,? Bef, ? Size, ? After, ? S_out)

defined in the ISO standard

True when S and S_out are strings such that the S_out has size Size and is a sub-string of S, Bef is the number of characters before, and After the number of characters afterwards

Note that S must always be known, but S_out can be unbound when calling this built-in If all the arguments for sub_string/5 but S are unbound, the built-in will generate all possible sub-strings of S

Accepts both atoms and strings

Macro Definition Documentation

◆ CastToNumeric

#define CastToNumeric (   x)    CastToNumeric__(x PASS_REGS)

Definition at line 1080 of file atomic.c.

◆ HAS_CACHE_REGS

#define HAS_CACHE_REGS   1

Definition at line 39 of file atomic.c.

◆ SUB_ATOM_HAS_AFTER

#define SUB_ATOM_HAS_AFTER   4

Definition at line 2294 of file atomic.c.

◆ SUB_ATOM_HAS_ATOM

#define SUB_ATOM_HAS_ATOM   16

Definition at line 2296 of file atomic.c.

◆ SUB_ATOM_HAS_MIN

#define SUB_ATOM_HAS_MIN   1

Definition at line 2292 of file atomic.c.

◆ SUB_ATOM_HAS_SIZE

#define SUB_ATOM_HAS_SIZE   2

Definition at line 2293 of file atomic.c.

◆ SUB_ATOM_HAS_UTF8

#define SUB_ATOM_HAS_UTF8   32

Definition at line 2297 of file atomic.c.

◆ SUB_ATOM_HAS_VAL

#define SUB_ATOM_HAS_VAL   8

Definition at line 2295 of file atomic.c.

Function Documentation

◆ Yap_InitAtomPreds()

void Yap_InitAtomPreds ( void  )

Definition at line 2866 of file atomic.c.

◆ Yap_InitBackAtoms()

void Yap_InitBackAtoms ( void  )

Definition at line 2852 of file atomic.c.

Variable Documentation

◆ name

wchar_t ** name

Definition at line 585 of file SWI-Prolog.h.

Macros

#define HAS_CACHE_REGS   1
 
#define CastToNumeric(x)   CastToNumeric__(x PASS_REGS)
 
#define SUB_ATOM_HAS_MIN   1
 
#define SUB_ATOM_HAS_SIZE   2
 
#define SUB_ATOM_HAS_AFTER   4
 
#define SUB_ATOM_HAS_VAL   8
 
#define SUB_ATOM_HAS_ATOM   16
 
#define SUB_ATOM_HAS_UTF8   32
 

Functions

void Yap_InitBackAtoms (void)
 
void Yap_InitAtomPreds (void)
 

Variables

char ** name