- LISP Tutorial
- LISP - Home
- LISP - Overview
- LISP - Environment
- LISP - Program Structure
- LISP - Basic Syntax
- LISP - Data Types
- LISP - Macros
- LISP - Variables
- LISP - Constants
- LISP - Operators
- LISP - Decisions
- LISP - Loops
- LISP - Functions
- LISP - Predicates
- LISP - Numbers
- LISP - Characters
- LISP - Arrays
- LISP - Strings
- LISP - Sequences
- LISP - Lists
- LISP - Symbols
- LISP - Vectors
- LISP - Set
- LISP - Tree
- LISP - Hash Table
- LISP - Input & Output
- LISP - File I/O
- LISP - Structures
- LISP - Packages
- LISP - Error Handling
- LISP - CLOS
- LISP Useful Resources
- Lisp - Quick Guide
- Lisp - Useful Resources
- Lisp - Discussion
LISP - Dolist Construct
The dolist construct allows iteration through each element of a list.
For example, Create a new source code file named main.lisp and type the following code in it −
(dolist (n '(1 2 3 4 5 6 7 8 9)) (format t "~% Number: ~d Square: ~d" n (* n n)) )
When you click the Execute button, or type Ctrl+E, LISP executes it immediately and the result returned is −
Number: 1 Square: 1 Number: 2 Square: 4 Number: 3 Square: 9 Number: 4 Square: 16 Number: 5 Square: 25 Number: 6 Square: 36 Number: 7 Square: 49 Number: 8 Square: 64 Number: 9 Square: 81
lisp_loops.htm
Advertisements