Database Reference
In-Depth Information
This new version works a lot like the last one. It first pulls the first item from the list and
then adds it to the result. It also removes duplicates of the first item from the rest of the list
(using Substitute() ). But instead of adding that to the result, it sends the entire remaining
list through RemoveDuplicates() . If you assume RemoveDuplicates() already works, then
it removes duplicates from the rest of the list. You take care of the first line using your calcu-
lation skills. Then you rely on the function itself to take care of all the rest. Notice that the
new list that's passed to RemoveDuplicates() starts with the second line of the original list.
So when the function runs again, the second line becomes the first, and the function takes
care of it. Unfortunately, this process goes on forever, which is probably not exactly what
you want.
Figure 16-5. You can switch to the Custom Function window in step 2, if you want to or you can
wait until you've got the whole thing working. Like the regular Specify Calculation window, Edit
Custom Function will analyze your calculation when you click OK, so make sure to define the func-
tion's parameter(s) to avoid an error message telling you that the parameters can't be found.
You'll finish this function in step 3.
Step 3: Find a Stopping Point
You now have two of the three critical components of a recursive function: You're manually
doing the first part of the job, and you're telling recursion to do the rest. If you leave the
Search WWH ::




Custom Search