Forums > MaxMSP

Simple functional programming in Max

February 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:

http://hanshoglund.se/downloads/functionalmax/functional.zip

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.

Attachments:
  1. functional.zip


jln
February 14, 2010 | 4:38 pm

Have you seen the following thread ? http://www.cycling74.com/forums/topic.php?id=14524#post-77661 I guess you’ll find it interesting.

Best,
jln


February 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.


February 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. –

February 18, 2010 | 10:38 pm

Here is an updated version in case anyone is interested.

http://hanshoglund.se/downloads/functionalmax/functional2.zip


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