Array Initialization: Difference between revisions

→‎Mathematica: Covered in Creating an Array
(→‎Mathematica: Covered in Creating an Array)
Line 181:
Prelude Data.Array> newArr (0,0) (5,5) 0
array ((0,0),(5,5)) [((0,0),0),((0,1),0),((0,2),0),((0,3),0),((0,4),0),((0,5),0),((1,0),0),((1,1),0),((1,2),0),((1,3),0),((1,4),0),((1,5),0),((2,0),0),((2,1),0),((2,2),0),((2,3),0),((2,4),0),((2,5),0),((3,0),0),((3,1),0),((3,2),0),((3,3),0),((3,4),0),((3,5),0),((4,0),0),((4,1),0),((4,2),0),((4,3),0),((4,4),0),((4,5),0),((5,0),0),((5,1),0),((5,2),0),((5,3),0),((5,4),0),((5,5),0)]
</lang>
 
==[[Mathematica]]==
Creating an array is just done by using Set and giving a symbol and a list. A list can contain ''anything'', and of any type. Elements don't have to be of the same type.
<lang Mathematica>
a={1,3,3,7};
b={"L","ee","t"};
c={1,Pi,"L",a};
</lang>
 
Anonymous user