Wiki Home

Validate An Algorithm With Another

Namespace: VFP
A useful practice in problem solving is to validate an algorithm with another.For example
see "How to solve it" by G. Polya, ISBN 069111966X .
In VFP we can use the #if ...#endif directive and the assert command to our advantage.
Put in a very simplistic way, we can exemplify this technique with the following code:
set asserts on
#if file("develop.doc")
   for i=1 to ln_DataOne
   Assert ln_ResultFirst=ln_Sum Message "The algorithms have different results"

The use of file("Develop.doc") is to simulate a global variable and when develop.doc is
removed from the current directory the second algorithm is not executed.
Contributors Eduardo Díaz Guerrero
Category Code Samples
( Topic last updated: 2004.05.17 04:52:40 PM )