Download Maple Advanced Programming Guide

Transcript
2.3 Packages
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> end
• 83
0
else
1 + length( tail( lst ) )
end if
end proc;
member := proc( item, lst )
if nullp( lst ) then
false
elif item = head( lst ) then
true
else
procname( item, tail( lst ) )
end if
end proc;
map := proc( p, lst )
if nullp( lst ) then
nil
else
pair( p( head( lst ) ),
procname( p, tail( lst ) ) )
end if
end proc;
append := proc( lst1, lst2 )
if nullp( lst1 ) then
lst2
else
pair( head( lst1 ),
procname( tail( lst1 ), lst2 ) )
end if
end proc;
reverse1 := proc( sofar, todo )
if nullp( todo ) then
sofar
else
procname( pair( head( todo ), sofar ),
tail( todo ) )
end if
end proc;
reverse := lst -> reverse1( nil, lst );
setup();
module:
Normally, a package definition like this would be entered into a Maple
source file using a text editor, or in a worksheet using the Maple graphical
user interface. In either case, the definition would then be followed by a
call to the savelib procedure using the name of the module as its sole