when-empty ( seq quot -- )
Factor handbook » The language » Collections » Sequence operations » Control flow with sequences

Prev:if-empty ( ..a seq quot1: ( ..a -- ..b ) quot2: ( ..a seq -- ..b ) -- ..b )
Next:unless-empty ( seq quot -- )


Vocabulary
sequences

Inputs
seqa sequence
quotthe first quotation of an if-empty


Outputs
None

Word description
Makes an implicit check if the sequence is empty. An empty sequence is dropped and the quot is called.

Examples
This word is equivalent to if-empty with an empty second quotation:
USING: sequences prettyprint ; { } [ { 4 5 6 } ] [ ] if-empty .
{ 4 5 6 }

USING: sequences prettyprint ; { } [ { 4 5 6 } ] when-empty .
{ 4 5 6 }


Definition