Next / Previous / Index / ITC Help System / Publications / Site map / NM Tech homepage

Generating the elements of an Icon list

Tech Computer Center logo

Icon's ``!'' operator, applied to a list, generates the elements of that list. For example, this expression would write each element of list ``L'' on a separate line:

    every write ( ! L );
Here's another example. This program reverses the lines from its input by pushing them onto a stack, and then generating the stack's elements:
    procedure main()
      L  :=  [];    # Create an empty list
      while push ( L, read ( ) );  # Push each line
      every write ( ! L );         # Generate & write lines
The ``while'' loop reads each lines and adds it to the front of the list ``L''. The ``!'' operator generates the elements of the list one at a time, and the ``every'' iterates over the generated values as they are written.
Next: Sorting an Icon list
See also: Using the list type in Icon
Previous: Using Icon lists as queues
Site map
Index: Keyword index to help pages
Help: New Mexico Tech Information Technology and Communications: Help System
ITC Publications
To report a problem: File a ticket
Send mail to the User consultant on duty or call them at 575-835-5437
Home: About New Mexico Tech

John Shipman,
Last updated: 1996/10/30 00:01:49 UT
QR two-dimensional bar code