All Manuals > LispWorks® User Guide and Reference Manual > 37 The HCL Package

string=-limited

string-equal-limited Functions

Summary

Compare two string up to the length of the second string.

Package

hcl

Signatures

string=-limited string1 string2 &optional start1 => boolean

string-equal-limited string1 string2 &optional start1 => boolean

Arguments
string1, string2
A string designator.
start1
An integer.
Values
boolean
A boolean.
Description

The functions string=-limited and string-equal-limited compare string1 and string2, with the comparison limited by the length of string2. string=-limited compares the characters as if using char=, while string-equal-limited compare the characters as if using char-equal.

start1 defaults to 0, and specifies an index into string1 where the comparison should start.

If start1 plus the length of string2 is bigger than the length string1, then false is returned. Otherwise, the part of string1 starting from start1 is compared with string2 up to the length of string2, and true is returned if the characters are the same.

Notes

string=-limited and string-equal-limited are intended to simplify comparison in typical cases where you read a string from "somewhere" (for example, a line from a configuration file), and want to check if the start of this string matches something. In particular, they avoid the need to check the length of the strings.

See also

string-equal
string=


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:35