[ Strings and Atoms | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]
string_length(+String, ?Length)
Succeeds if Length is the length of the string String.
- +String
- String.
- ?Length
- Integer or variable.
Description
The length of the string String is unified with Length.
Fail Conditions
Fails if Length does not unify with the length of String.
Resatisfiable
No.
Exceptions
- (4) instantiation fault
- String is not instantiated (non-coroutine mode only).
- (5) type error
- String is instantiated, but not to a string.
- (5) type error
- Length is neither an integer nor a variable.
Examples
Success:
string_length("Peter ",X). (gives X=6).
string_length("Peter ",6).
string_length("401.35",6).
Fail:
string_length("Peter",6).
Error:
string_length(Str,Len). (Error 4).
string_length(Str,6). (Error 4).
string_length("small",5.0). (Error 5).
string_length(Str,instantiated). (Error 5).
string_length(Str,46.2) (Error 5).
string_length('this one',L). (Error 5).
See Also
append_strings / 3, atom_length / 2, concat_strings / 3