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.
                                          

Attachment: arithmetic.pd
Description: Binary data

_______________________________________________
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to