Maple Professional
Maple Academic
Maple Student Edition
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professional
MapleSim Academic
Maple T.A. - Testing & Assessment
Maple T.A. MAA Placement Test Suite
Möbius - Online Courseware
Machine Design / Industrial Automation
Aerospace
Vehicle Engineering
Robotics
Power Industries
System Simulation and Analysis
Model development for HIL
Plant Modeling for Control Design
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematics Education
Engineering Education
High Schools & Two-Year Colleges
Testing & Assessment
Students
Financial Modeling
Operations Research
High Performance Computing
Physics
Live Webinars
Recorded Webinars
Upcoming Events
MaplePrimes
Maplesoft Blog
Maplesoft Membership
Maple Ambassador Program
MapleCloud
Technical Whitepapers
E-Mail Newsletters
Maple Books
Math Matters
Application Center
MapleSim Model Gallery
User Case Studies
Exploring Engineering Fundamentals
Teaching Concepts with Maple
Maplesoft Welcome Center
Teacher Resource Center
Student Help Center
macro - define a macro - abbreviation
Calling Sequence
macro(e1, e2,..., en)
Parameters
e[1], e[2], ..., e[n]
-
zero or more equations
Description
The macro facility is a simple abbreviation facility to be used when writing Maple functions and library code.
The effect of invoking macro(f = g) is that Maple when reading input from the terminal or a file will transform all occurrences of f on input into g except for parameters and local variables.
The arguments to macro are equations which are neither evaluated nor subjected to any existing macros. This means that you cannot define one macro in terms of another. You can however change the macro definition by doing macro(f = h). The command macro(f = f) will remove the macro definition for f.
Any Maple object, except a numerical constant, may appear on the left-hand side of f = g.
A typical use of the macro facility is the following. Suppose we are writing a Maple procedure that uses the Maple library routine combinat['fibonacci'] in several places, and we wish to avoid having to type this long function name every time it is used. We can define the following: macro(F=combinat['fibonacci']), and then the symbol F can be used as an abbreviation for combinat['fibonacci'] throughout the remainder of the code.
Macros cannot have arguments. Use procedures with option inline to achieve the effect of macros with arguments. The $define facility can also be used when source code is being redirected into the Command-line version of Maple in batch mode.
Thread Safety
The macro command is thread-safe as of Maple 15.
For more information on thread safety, see index/threadsafe.
Examples
See Also
$define, alias, inline, subs
Download Help Document