February 8, 201115 yr I have several calculations that require a number to loop incrementally until the calculation is satisfied. What is the most simple counter that I can write as a custom function in the form of something like: Counter(Increment) ?
February 8, 201115 yr It really depends on the specifics. Custom functions are recursive, not iterative. Most often, you would call the next iteration with some parameter reduced by 1, until it runs out.
February 8, 201115 yr Author I understand. I'd have to make my calculations work recursively. The number that I want to increment is a divisor that just goes from 1 (+1) to whenever the result is true. It's just much easier to think of this calculation iteratively. I'd put it in a script, but that would probably run slower than using a custom function. The calculation is used for every new record and has a lot of dependencies that get updated.
February 8, 201115 yr Well, "the most simple counter" would be a parameter named counter, initialized to 1. a divisor that just goes from 1 (+1) to whenever the result is true. Not sure what that means - couldn't you use the Mod() function to get the result without recursing? Edited February 8, 201115 yr by comment
February 8, 201115 yr Author Well, "the most simple counter" would be a parameter named counter, initialized to 1. Not sure what that means - couldn't you use the Mod() function to get the result without recursing? One of the tests and results in a case() function that I want to apply it to is something like this, where n is the divisor starting from 2, then 3, 4, and so on until it evaluates as true. If there's a remainder, it gets passed on to another calculation field that does something similar, and then a few more times. This is actually part of a slew of calculation fields that deal with remainders of an original input value. Mod() doesn't always give me the proper remainder and that's the first function that I worked with before my idea of using iterative increments. WSTurnPageSides ≥ PageFit / n ; PageFit / n ;
February 8, 201115 yr I believe the condition: WSTurnPageSides ≥ PageFit / n can be rewritten as: n ≥ PageFit / WSTurnPageSides and the smallest integer n that will satisfy the condition can be calculated as = Ceiling ( PageFit / WSTurnPageSides )
February 8, 201115 yr Author I believe the condition: WSTurnPageSides ≥ PageFit / n can be rewritten as: n ≥ PageFit / WSTurnPageSides and the smallest integer n that will satisfy the condition can be calculated as = Ceiling ( PageFit / WSTurnPageSides ) That's working very well so far and it reduces a lot of calculations into one simple line. I wrote the condition like this before but missed the Ceiling() function. Thanks again for your help.
Create an account or sign in to comment