20L-2367 A3.docx - Assignment 3 Question 1: Table in SNOBOL...

This preview shows page 1 - 2 out of 5 pages.

Assignment 3Question 1:Table in SNOBOLA "table" is similar to a one-dimensional array, with two important differences. First, a table's size is notfixed; it extends itself automatically whenever a new element is added to it. Second, table subscripts arenot limited to integers, but may be any SNOBOL4 data type. Strings and patterns may be used assubscripts. Tables combine the idea of associative programming with the data grouping of arrays.Tables are created by the SNOBOL4 function TABLE. No arguments are required, since a table's size isnot fixed. The function returns a table pointer, which you store in a variable. Like arrays, table elementsare referenced by applying subscripts to the variable. Try this example with CODE.SNO:T = TABLE()T['ROSE'] = 'RED'T['N'] = 6OUTPUT = T['N'] T['THE'] T['ROSE']6REDFLOWER = 'ROSE'T[FLOWER] = T[FLOWER] ',THORNS'OUTPUT = T[FLOWER]RED,THORNSHere, strings have been used as table subscripts. The concept of an "out-of-bounds" subscript does not

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 5 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
Mr. Amir Wali
Tags
Pattern matching

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture