Packed Array OperationsThe important detail of packed arrays is that they work exactly like lists except for the packed array specific functions described above. For example, SameQ on the packed and non-packed version of a list will return True. In[1]:=  |
Out[2]=
|
The packed and non-packed versions will behave the same in the pattern matcher. In[3]:=  |
Out[3]=
|
In[4]:=  |
Out[4]=
|
Many functions can work more efficiently with packed arrays compared with unpacked lists, but the results will be the same, whether a packed or an unpacked version is used. In order to maintain consistency, the system must, on occasion, unpack a packed array. Because this is a potential source of inefficiency, a message is available to let you know that something has become unpacked. You can enable this message with a system option. This sets the system option and creates a packed array to use as an example. In[5]:=  |
Out[7]=
|
Now if a real number is inserted into the packed array, it must be unpacked and a message is produced. This message can warn you that your code may not run as efficiently. In[8]:=  |
It is usually a good idea to turn the message off again. In[9]:=  |
|