Sometimes multiple conditions are required to define a function.  For example, a job may pay $10 per hour for the first 40 hours per week, $15 per hour for additional hours through 50 per week, and $20 per hour for hours exceeding 50 per week.


Nested IF expressions are a convenient way to express multiple conditions.  Any clause of an IF expression can itself be an IF expression.  For example, the above pay schedule can be entered as


IF(h <= 40, 10h, IF(h <= 50, 400 + 15(h - 40), 550 + 20(h - 50)))


IF expressions can be nested arbitrarily deep; however, it is usually better to subdivide complicated IF expressions into more comprehensible components by defining auxiliary helper functions.


Other Programming in DERIVEProgramming 

Created with the Personal Edition of HelpNDoc: Generate Kindle eBooks with ease