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 • 25old _set := {2, 3, 4}> new_set := old_set union {2, 5};new_set := {2, 3, 4, 5}> third_set := old_set minus {2, 5};third _set := {3, 4}ArraysArrays are an extension of the concept of the list data structure. Thinkof a list as a group of items in which you associate each item with a positiveinteger, its index, that represents its position in the list. The Maplearray data structure is a generalization of this idea. Each element is stillassociated with an index, but an array is not restricted to one dimension.In addition, indices can also be zero or negative. Furthermore, youcan define or change the array’s individual elements without redefining itentirely.Declare the array so Maple knows the dimensions you want to use.> squares := array(1..3);squares := array(1..3, [])Assign the array elements. Multiple commands can be entered at onecommand prompt provided each ends with a colon or semicolon.> squares[1] := 1; squares[2] := 2^2; squares[3] := 3^2;squares 1 := 1squares 2 := 4squares 3 := 9Or, if you prefer, do both simultaneously.> cubes := array( 1..3, [1,8,27] );

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

Saved successfully!

Ooh no, something went wrong!