This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Functional Programming

Higher-order functions and other utilities for functional programming

MuPAD Functions

@ Compose functions
@@ Iterate a function
copyClosure Copies the lexical closure of a procedure
discont Discontinuities of a function
funcenv Create a function environment
map Apply a function to all operands of an object
maprat Apply a function to a rationalized expression
operator Define a new operator symbol
fp::apply Apply function to arguments
fp::bottom Function that never returns
fp::curry Curry an n-ary function
fp::expr_unapply Create a functional expression from an expression
fp::fixargs Create function by fixing all but one argument
fp::fixedpt Returns fixed point of a function
fp::fold Create function which iterates over sequences
fp::nest Repeated composition of function
fp::nestvals Repeated composition returning intermediate values
fp::unapply Create a procedure from an expression
misc::breakmap Stops the mapping currently done by maprec
misc::maprec Map a function to subexpressions of an expression
Pref::typeCheck Type checking of formal parameters
Pref::warnDeadProcEnv Warnings about wrong usage of lexical scope
prog::getname Name of an object
prog::getOptions Get and verify options within a procedure
prog::isGlobal Information about reserved identifiers

Examples and How To

Access Arguments of a Procedure

The terms parameters and arguments are often used interchangeably.

Test Arguments

When writing a MuPAD® procedure, you can specify the type of arguments accepted by the procedure.

Verify Options

For many standard MuPAD procedures, you can use different options.

Data Collection

Suppose the data that you want to collect is generated element-by-element and you know in advance how many elements will be generated.

Variables Inside Procedures

When you call a procedure, MuPAD allocates memory for the local variables, marks them as uninitialized, and evaluates the body of the procedure.

Utility Functions

You can define utility functions inside a procedure.

Private Methods

Create private methods by using closures.

Calls by Reference and Calls by Value

When calling a procedure with some arguments, you expect the procedure to assign these values for its local variables and perform some computations with those variables.


Functional Programming

Use only in the MuPAD Notebook Interface.

The misc Library

Use only in the MuPAD Notebook Interface.

Was this topic helpful?