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.

5.3 Structural Manipulations • 173> type( 3, numeric );true> type( cos(1), numeric );falseThe syntax of select here passes the third argument, numeric, tothe type command.> select( type, L, numeric );[8, 2.95]See this section, pages 179–185, for more information on types andusing select and remove on a general expression.Merging Two ListsSometimes you need to merge two lists. Here is a list of x-values and alist of y-values.> X := [ seq( ithprime(i), i=1..6 ) ];X := [2, 3, 5, 7, 11, 13]> Y := [ seq( binomial(6, i), i=1..6 ) ];Y := [6, 15, 20, 15, 6, 1]To plot the y-values against the x-values, construct a list of lists: [[x1,y1], [x2,y2], ... ]. That is, for each pair of values, construct atwo-element list.> pair := (x,y) -> [x, y];pair := (x, y) → [x, y]The zip command can merge the lists X and Y according to the binaryfunction pair.

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

Saved successfully!

Ooh no, something went wrong!