12.07.2015 Views

Learning Guide Learning Guide

Learning Guide Learning Guide

Learning Guide Learning Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.5 Basic Types of Maple Objects • 27> pwrs[2,1] := 2: pwrs[2,2] := 4: pwrs[2,3] := 8:> pwrs[3,1] := 3: pwrs[3,2] := 9: pwrs[3,3] := 27:> print(pwrs);⎡ ⎤1 1 1⎣ 2 4 8 ⎦3 9 27You can select an element by specifying both the row and column.> pwrs[2,3];8You can define a two-dimensional array and its elements simultaneouslyby using a similar method employed for the one-dimensional exampleshown earlier. To do so, use lists within lists. That is, make a listwhere each element is a list that contains the elements of one row of thearray. Thus, you could define the pwrs array as follows.> pwrs2 := array( 1..3, 1..3, [[1,1,1], [2,4,8], [3,9,27]] );⎡ ⎤1 1 1pwrs2 := ⎣ 2 4 8 ⎦3 9 27Arrays are by no means limited to two dimensions, but those of higherorder are more difficult to display. You can declare all the elements of thearray as you define its dimension.> array3 := array( 1..2, 1..2, 1..2,> [[[1,2],[3,4]], [[5,6],[7,8]]] );

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!