
Generation of a nested loop structure

Eduard Kas
In the attached procedure file I would like to generate a second loop so that in case of years = 5, I would arrive at five different outcomes, namely the vaues for year one; years one and two, years one, two, and three, years one up to and including four, and years one up to and including five. I have tried to generate a nested loop structure, but all what I achieved so far is that I only got the final year outcome (that is, the year 5 value in the example). The attached lines of code only relate to my first loop, that does what it is required to do. I have shown none of my failed attempts to generate a nested loop. I would highly appreciate any help. Thank you in advance.
Eduard

Make/O/N=(years) Results
and then store the result per year in it, such that your do-while loop contains something like this:
Results[i] = //here comes your expression
then you don't need an extra loop and you don't need to think about how to return the five values.
Cheers
C
BTW: it would be better if you can post your code here as text, instead of posting a picture ....then it's easier to work on it
May 27, 2010 at 12:28 am - Permalink
where p is the value for the 'years' parameter.
May 27, 2010 at 01:15 am - Permalink
Many thanks for the ideas both of you provided. I followed the first advice, partly because I did not see how to implement an approach of combining ChrLie's approach with my own function. Is it meant that the code results = Marketvalue (Inflation,Discountrate, Pricerise, Buildingcostrise, Rent, WOZ, Opcosts, Maintenance, WOZfactor, p) can be used and if so, where am I suggested to put this line of code?
Think that after all I found the appropriately way to show the code as text (see the lines below).
The function now does exactly what I like to do with it.
Eduard
May 27, 2010 at 10:49 pm - Permalink
You can the write
Make/O/N=(years) Results
Results=Marketvalue (Inflation,Discountrate, Pricerise, Buildingcostrise, Rent, WOZ, Opcosts, Maintenance, WOZfactor, p)
using the above modified procedure straight into the command window.
BTW what purpose serves the variable sum in your code? This can be ambiguous, because it is also an Igor built-in function.
Andreas
May 28, 2010 at 12:27 am - Permalink
Eduard
June 14, 2010 at 03:12 pm - Permalink
I believe the following will also work, be faster, and allow the return of the "present" value versus "year" in a wave if needed.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
June 14, 2010 at 04:15 pm - Permalink