Forums > MaxMSP

Simple functional programming in Max

Feb 14 2010 | 4:05 pm

Hi everyone,

After working intensively on a bigger project, I hit the wall with a problem that required some simple recursive calls: unfortunately, that part had to be implemented in Max alone.

I came to muse on whether there were no easy way to enable functional style recursive calls in Max, and came up with three small abstractions that allows you to define and call a function (def, call and return). I’ve put them up with a sample factorial implementation.

Download here:

There seem to be some problems with stack space (mostly in Overdrive mode), but they seem to work quite efficiently otherwise.

What do you think? Maybe this could be expanded into some set of functional utilities.


Feb 14 2010 | 4:38 pm

Have you seen the following thread ? I guess you’ll find it interesting.


Feb 14 2010 | 4:43 pm

Don’t reinvent the wheel they say ;)

I actually remember trying those objects out ages ago, but I didn’t recall them today.

Feb 14 2010 | 7:25 pm

Actually, oo does not seem to support recusive calls, as seen in the patch below. Guess I have to stick to my objects for the moments (which use a simple zl stack to store return adresses and can call themselves as long as there is space on the stack).

— Pasted Max Patch, click to expand. —
Feb 18 2010 | 10:38 pm

Here is an updated version in case anyone is interested.

Viewing 5 posts - 1 through 5 (of 5 total)

Forums > MaxMSP