Книга: Practical Common Lisp
Iteration Control
Iteration Control
Most of the so-called iteration control clauses start with the loop keyword for
, or its synonym as
,[235] followed by the name of a variable. What follows after the variable name depends on the type of for
clause.
The subclauses of a for
clause can iterate over the following:
• Ranges of numbers, up or down, by specified intervals
• The individual items of a list
• The cons cells that make up a list
• The elements of a vector, including subtypes such as strings and bit vectors
• The pairs of a hash table
• The symbols in a package
• The results of repeatedly evaluating a given form
A single loop can have multiple for
clauses with each clause naming its own variable. When a loop has multiple for
clauses, the loop terminates as soon as any for
clause reaches its end condition. For instance, the following loop:
(loop
for item in list
for i from 1 to 10
do (something))
will iterate at most ten times but may stop sooner if list
contains fewer than ten items.
- 3.1.19 Modifying the Flow of Control
- Skipping an Iteration
- Iteration
- Equals-Then Iteration
- Introduction to Microprocessors and Microcontrollers
- Data sending and control session
- Data Binding Using the GridView Control
- Configure Access Control
- Using the kill Command to Control Processes
- 3.4.4. Concurrency Control
- Controlling Services at Boot with Administrative Tools
- Basic Shell Control