Functional Programming Constructs

A set of files for treating many operations, like "if", "for", and even "()", as functions.
Updated 1 Sep 2016

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

This set of files enables working more easily with functions of functions for concise and powerful code.
A few highlights of this way of working:

* Map multiple inputs to multiple functions and assign multiple outputs with a single line.

* Use conditionals (like "if"), loops, and recursion in anonymous functions.

A document with derivations and examples of these functions is included. See the readme.txt. Also, each function contains a 'help' entry with examples.

This submission requires strong familiarity with function handles and anonymous functions. If those aren't familiar terms, check the documentation first!

Cite As

Tucker McClure (2024). Functional Programming Constructs (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Files and Folders in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Updated license

The 'wrap' function returned all output arguments up to the highest selected. It now "wraps up" only the specifically requested arguments. (Thanks Harald.)

Fixed iif to accept function handles for conditions.