11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming 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.

6.2 <strong>Programming</strong> with Plotting Library Functions • 221• The loopplot command should also accept a number of plotting options.It should pass the options to the plot command inside theprocedure.Example 2 Inside a procedure, args is the sequence of arguments inthe call to the procedure, and nargs is the number of arguments. Thusargs[2..nargs] is the sequence of options passed to loopplot. Theloopplot procedure should pass all but its first argument, L, directlyto plot.> loopplot := proc( L::list( [constant, constant] ) )> plot( [ op(L), L[1] ], args[2..nargs] );> end proc:The version of loopplot in Example 2 gives an informative errormessage if you try to use it with improper arguments, and it also allowsplotting options.> loopplot( [[1, 2], [a, b]] );Error, invalid input: loopplot expects its 1stargument, L, to be of type list([constant, constant]),but received [[1, 2], [a, b]]> loopplot( L1, linestyle=DOT );363432302826245 6 7 8 9 10 11Exercise1. Improve loopplot so that it can handle the empty list as input.A Ribbon Plot ProcedureThis section illustrates a ribbonplot procedure to create a threedimensionalplot of a list of two-dimensional formulæ or functions.

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

Saved successfully!

Ooh no, something went wrong!