[PD] need help with recursive patching for arithmetic patch
Liam Goodacre
liamg_uw at hotmail.com
Mon Nov 9 15:13:24 CET 2015
I'm trying to make a patch which can simplify arithmetic expressions given as a single message. I want to, for example, send it the message "( 2 + 5 )" and get "7", or send it "foo ( 8 / 4 )" and get "foo 2". This much I have achieved, using [list-drip] and [route] to identify the data inside brackets, and [list-reduce] to perform the arithmetic. The difficulty I'm having is in getting it to work recursively, so that eg. "bar ( 5 - ( 3 - 2 ) )" gives "bar 1". Ideally, the abstraction would be able to process any number of bracket-levels, just as a scientific calculator does.
I know that programming recursively on PD is not for the faint hearted, and I feel pretty much out of my depth. If anyone can point me in the right direction, I will be most grateful. Alternatively, if it turns out to be too hard, I'll settle for what I've made already.
I'm attaching the patch, although I think it's pretty far removed from what the solution will look like. Note that I'm using Zexy and list-abs here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20151109/f5f7d42c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: arithmetic.pd
Type: application/octet-stream
Size: 2381 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20151109/f5f7d42c/attachment.obj>
More information about the Pd-list
mailing list