12.07.2015 Views

Learning Guide Learning Guide

Learning Guide Learning Guide

Learning Guide Learning Guide

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.3 Structural Manipulations • 169In this example, the double colon (::) indicates a property assignment.In general, it is used for type checking. For more information, referto ?type.For more information about the assuming command, refer to ?assuming.5.3 Structural ManipulationsStructural manipulations include selecting and changing parts of an object.They use knowledge of the structure or internal representation of anobject rather than working with the expression as a purely mathematicalexpression. In the special cases of lists and sets, choosing an element isstraightforward.> L := { Z, Q, R, C, H, O };L := {O, R, Z, Q, C, H}> L[3];ZSelecting elements from lists and sets is easy, which makes manipulatingthem straightforward. The concept of what constitutes the parts ofa general expression is more difficult. However, many of the commandsthat manipulate lists and sets also apply to general expressions.Mapping a Function onto a List or SetYou may want to apply a function or command to each of the elementsrather than to the object as a whole. The map command does this.> f( [a, b, c] );f([a, b, c])> map( f, [a, b, c] );[f(a), f(b), f(c)]

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

Saved successfully!

Ooh no, something went wrong!