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

How Icon positions are numbered

Tech Computer Center logo

In Icon, the characters in a string are identified by their position, counting from 1. The positions refer to the gaps between the characters, not to the characters themselves. Positive numbers count from the left starting at 1, and nonpositive numbers count from the right starting at 0. For example, the positions of the gaps in the string "abc" are numbered like this:

   -3    -2    -1     0
    +-----+-----+-----+
    |  a  |  b  |  c  |
    +-----+-----+-----+
    1     2     3     4
So position 1 (or -3) refers to the position before the first character; position 2 (or -2) refers to the position before the second character; and so on. Position 0 is always the end of the string.
Next: Finding the size of an Icon string
See also: Using strings in Icon
Previous: Reading an input line in Icon
Site map
Index: Keyword index to help pages
Help: New Mexico Tech Computer Center: Help System
TCC Publications
Home: About New Mexico Tech

John Shipman, john@nmt.edu

Last updated: 1996/01/06 21:12:57 UT
URL: http://www.nmt.edu/tcc/help/lang/icon/positions.html