This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Functional Programming

Higher-order functions and other utilities for functional programming

MuPAD Functions

@Compose functions
@@Iterate a function
copyClosureCopies the lexical closure of a procedure
discontDiscontinuities of a function
funcenvCreate a function environment
mapApply a function to all operands of an object
mapratApply a function to a rationalized expression
operatorDefine a new operator symbol
fp::applyApply function to arguments
fp::bottomFunction that never returns
fp::curryCurry an n-ary function
fp::expr_unapplyCreate a functional expression from an expression
fp::fixargsCreate function by fixing all but one argument
fp::fixedptReturns fixed point of a function
fp::foldCreate function which iterates over sequences
fp::nestRepeated composition of function
fp::nestvalsRepeated composition returning intermediate values
fp::unapplyCreate a procedure from an expression
misc::breakmapStops the mapping currently done by maprec
misc::maprecMap a function to subexpressions of an expression
Pref::typeCheckType checking of formal parameters
Pref::warnDeadProcEnvWarnings about wrong usage of lexical scope
prog::getnameName of an object
prog::getOptionsGet and verify options within a procedure
prog::isGlobalInformation 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?