Robert M. Corless
Department of Applied Mathematics
University of Western Ontario
London, Canada

Copyright 2001 by Robert M. Corless
All rights reserved

Programming in Maple 

Программирование в Maple

 Variable number or type of arguments 

Переменное число или тип аргументов

> restart;
> f := proc( x, y ) if x < 1 then 1 elif y < 3 then 2 else 3 end if end proc:
> f( 0 );

1

> f( 1, 2 );

2

> f( 1 );
Error, (in f) f uses a 2nd argument, y, which is missing
> restart;
> ?typematch
> my_int := proc( f, x::{name,name=anything..anything} ) local a, b, s, t;
if typematch( x, t::name=a::anything..b::anything) then int( f, t=a..b )
else int( f, x=0..1 ) end if end proc:
> my_int( sin(x), x );

-cos(1)+1

> my_int( sin(x), x=0..Pi );

2

> my_int( cos(q), q=-2..2 );

2*sin(2)

> my_int( exp(w), 0..1=w );

Error, invalid input: my_int expects its 2nd argument, x,

 to be of type {name = anything .. anything, name},
 but received 0 .. 1 = w

С официального разрешения                    © 2002 Waterloo Maple, Inc

 
Hosted by uCoz