Hi,
I am mostly a scientist type--I use other peoples algorithms as much as possible, and spend my time writing glorified macros. Recently, I have needed a way to program in a simple recursion (details follow) and I was wondering if there was an elegant and useful way.
The method matters to me more than the actual program--I need to implement the following problem in Labview, MatLab, and IGOR:
If I have a text form like so 3*(a,10)(b,20) I generate a list of
a 10
b 20
a 10
b 20
a 10
b 20
This is to control think film deposition, for those of you interested. Now, in order to make more interesting structures, I would like to be able to have multiple parantheses. I currently can do things like 5*(a,10)(b,10)+3(c,20)(d,30) and use the plus to make series of independent superlattices. It would be better if I could do things like 5*(3*(a,10)(b,20)+1*(c,2)) and even longer sets, with multiple levels parantheses.
I think there ought to be a clever way of doing this, and I suspect good programmers (you are out there!) will have done this many, many times. I have managed to make the algorithm I used a bit better, but I think my understanding of algorithm building is too crude.
Anyone have some good ideas? General is preferred, as I have to pretty much implement from scratch in multiple environments, so a really great one line perl script doesn't help much here.
Thanks
B
I am mostly a scientist type--I use other peoples algorithms as much as possible, and spend my time writing glorified macros. Recently, I have needed a way to program in a simple recursion (details follow) and I was wondering if there was an elegant and useful way.
The method matters to me more than the actual program--I need to implement the following problem in Labview, MatLab, and IGOR:
If I have a text form like so 3*(a,10)(b,20) I generate a list of
a 10
b 20
a 10
b 20
a 10
b 20
This is to control think film deposition, for those of you interested. Now, in order to make more interesting structures, I would like to be able to have multiple parantheses. I currently can do things like 5*(a,10)(b,10)+3(c,20)(d,30) and use the plus to make series of independent superlattices. It would be better if I could do things like 5*(3*(a,10)(b,20)+1*(c,2)) and even longer sets, with multiple levels parantheses.
I think there ought to be a clever way of doing this, and I suspect good programmers (you are out there!) will have done this many, many times. I have managed to make the algorithm I used a bit better, but I think my understanding of algorithm building is too crude.
Anyone have some good ideas? General is preferred, as I have to pretty much implement from scratch in multiple environments, so a really great one line perl script doesn't help much here.
Thanks
B