empty

empty <iterable>

Test whether an iterable has no elements.

Arguments

Returns

A booltrue if the iterable yields nothing, false if it has at least one element.

Examples

after command (say) {
  unless [empty [creatures $self]]
  do "say We are not alone here."
}

When the owner's room holds at least one living creature, [empty ...] is false, the unless guard is satisfied, and the mob speaks. In the debug world (mob Puff plus other creatures in room 1) this runs and the mob speaks.

after command (say) {
  do "say empty? [empty [words "x"]]"
}

[words "x"] yields one word, so [empty ...] evaluates to false and the mob says "empty? false." ([empty [list]], over an empty list, evaluates to true.)

See also