Induction 

Inductive properties reflect those of their operand(s). They are usually formulated for the inductive case. 

For example, the factorial function for any argument should obey the factorial definition:

scala> def factorial(n: Long): Long = if (n < 2) n else n * factorial(n-1)
factorial: (n: Long)Long

scala> forAll((a: Byte) => a > 2 ==>
(factorial(a) == a * factorial(a - 1))).check
+ OK, passed 100 tests.

Which is, of course, a conditional property for n > 2, which we specify using the implication operator ==> (more about this operator later).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.224.226