11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

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

16 • Chapter 2: Procedures, Variables, and Extending Maplehh := x → h(x + 1)> hh(x,y);Error, (in h) h uses a 2nd argument, y, which ismissingMultivariate Functions To modify shift to work with multivariatefunctions, rewrite it to accept the additional parameters.In a procedure, args is the sequence of actual parameters, andargs[2..-1] is the sequence of actual parameters except the first one.For more information on the selection operation ([ ]), refer to Chapter 4of the Introductory <strong>Programming</strong> <strong>Guide</strong>. It follows that the procedurex->f(x+1,args[2..-1]) passes all its arguments except the first directlyto f.> shift := (f::procedure) -> ( x->f(x+1, args[2..-1]) ):> hh := shift(h);hh := x → h(x + 1, args 2..−1 )> hh(x,y);(x + 1) yThe function hh depends on h; if you change h, you implicitly changehh;> h := (x,y,z) -> y*z^2/x;h := (x, y, z) → y z2x> hh(x,y,z);y z 2x + 1

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

Saved successfully!

Ooh no, something went wrong!