
between(+From, +To, +Step, -Result)

   Generate integer values between From and To with Step increment.



Arguments
   From                Integer
   To                  Integer
   Step                Integer
   Result              A variable or an integer

Type
   Arithmetic

Description
   When first called, this predicate checks that From is less than or equal
   to To (or greater than or equal if Step is negative) and if so, it binds
   Result to From.  On backtracking it increments Result by Step until it
   is greater than To (less than To is Step is negative) and then it fails.




Modes and Determinism
   between(+, +, +, -) is nondet

Fail Conditions
   Fails if To is less than From (for positive Step), or From less than To (for negative Step)

Exceptions
     4 --- Input arguments are not instantiated.
     5 --- An argument is not an integer.
     6 --- Step is zero.
    24 --- An argument is not a number.

Examples
   
Success:
      between(1, 4, 1, X).
      between(5, 0, -2, X).
      between(2, 10, 3, 8).
      between(3, 3, 1, X).
Fail:
      between(2, 0, 1, X).
Error:
      between(1, 4, S, X).         (Error 4)
      between(1, 4, 0.1, X).       (Error 5)
      between(1, 4, 0, X).         (Error 6)
      between(1, 4, 1, a).         (Error 24)





See Also
   
