-
Language:
English
-
Language:
English
21.5. Fibonacci Example: Bootstrap Rule
rule Bootstrap when f : Fibonacci( sequence == 1 || == 2, value == -1 ) // multi-restriction then modify ( f ){ value = 1 }; System.out.println( f.sequence + " == " + f.value ); end
- When a
Fibonacci
object with a sequence field of 2 is asserted the Bootstrap rule is matched and activated along with the Recurse rule. - Note the multi-restriction on field
sequence
, testing for equality with 1 or 2. - When a
Fibonacci
object with a sequence of 1 is asserted the Bootstrap rule is matched again, causing two activations for this rule. The Recurse rule does not match and activate because thenot
conditional element stops the rule's matching as soon as aFibonacci
object with a sequence of 1 exists.