ListabilityIf you want to apply your own function to each element in a matrix, you may give your function the attribute Listable. This function squares each element and divides the result by 3. In[1]:=  |
In[3]:=  |
In[4]:=  |
Out[4]//MatrixForm=
|
When a listable operation is applied to a sparse array, it only operates on the elements that are actually stored (including the default element), so the value of fun[0] is only computed once. More information on Mathematica programming can be found in The Mathematica Book.
|