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

Using the table type in Icon

Tech Computer Center logo

An Icon table is a container where you can store and retrieve things using a key value. This is often used in situations where you want to look up something.

For example, suppose you want to translate the number of the day of the week (e.g., 3 for Tuesday) to a string giving the name of the day (e.g., "Tue"). You could do this with a list like so:

  dayNames := ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
so that a reference to ``dayNames[3]'' would produce the string "Tue".

But what if you want to do the opposite translation---from a day name to a day number? For this you'd use an Icon table. You can set up a table called ``dayNumbers'' so that ``dayNumbers["Tue"]'' will produce the value 3. Another term for this kind of structure is associative array.


Next: Creating your own record types in Icon
See also: Using data structures in Icon
Previous: Using the list type in Icon
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, john@nmt.edu
Last updated: 1996/04/24 00:03:51 UT
URL: http://www.nmt.edu/tcc/help/lang/icon/table.html
QR two-dimensional bar code