hasabbrev
hasabbrev <string> <iterable>
Test whether a string is a prefix abbreviation of some element of an iterable.
Each element is tested with the same rule as
isabbrev: <string> is a case-insensitive prefix of the
element.
Arguments
<string>— the abbreviation to look for.<iterable>— a list or any iterable. A bare string is not iterable; convert it first withwords. The elements compared against are treated as strings.
Returns
A bool — true if <string> abbreviates some element, false
otherwise (including when the iterable is empty).
Examples
after command (say) {
do "say abbrev? [hasabbrev al [words "alpha beta"]]"
}
"al" is a prefix of "alpha", so [hasabbrev ...] evaluates to true
and the mob says "abbrev? true."
after command (say) {
require [hasabbrev $arg [alias $self]]
do "say You named one of my keywords."
}
[alias $self] is the owner's keywords as a word
iterable. The require guard lets the
handler run only when what the actor typed ($arg) abbreviates one of those
keywords.