Using the copy() function in Icon |
|
The ``copy'' function is used to create a duplicate of an aggregate structure. For example, if ``L'' is a list containing five things, ``copy(L)'' returns a new list containing the same five things.
You can use the ``copy()'' function to avoid modifying a structure that has been passed into a procedure. Be aware, though, that the copying only proceeds for one level. If ``L'' is a list containing five records, then ``copy(L)'' gives you a new list, but this new list effectively points to the same five records, so if you modify a field in one of those records, it will still affect the same record pointed at by list ``L''.
This ends our Icon tutorial. There are a lot more useful features, though. For more information, see `References for the Icon programming language'.
|
John Shipman, john@nmt.edu
Last updated: 1996/01/06 21:12:57 UT URL: http://www.nmt.edu/tcc/help/lang/icon/copy.html |
|