Value Range
Scala provided range structures (Range and NumericRange) are implemented more as collections and this class is designed to close this void focusing on generic range operations
Range is defined with the following defs:
start
end
,- and
ordering
, which mks the above meaningful
Range has a notion that an element can be within the range, i.e. between start and end, or outside
Note. Range is implicitly converted to a let function, returning true
if an element is within Range and false
otherwise
Def
Check if within
Check if within
Returns true if this
range contains specified range
(1 <> 9) contains (3 <> 7) // Returns: true
(1 <> 5) contains (3 <> 7) // Returns: false
- Source
- __.scala
Check if within
Check if within
Returns true if this
range contains specified value
(1 <> 9) contains 3 // Returns: true
- Source
- __.scala
Inclusive check
Inclusive check
If true, the end
value is inclusive
(10 <>> 15) contains 15 // Returns: false
// Exclusive 15 does not contain 15
- Source
- __.scala
Extend to
Extend to
This
range is extended to contain the specified value
'A' <> 'C' extendTo 'G' // Returns: A <> G
'A' <> 'C' extendTo 'B' // Returns: A <> C
- Source
- __.scala
Union
Union
Returns range with out-most reaches of this
and specified
'A' <> 'C' join 'X' <> 'Z' // Returns: A <> Z
- Source
- __.scala
Optional intersection
Optional intersection
Optionally returns common intersection of this
and that
1 <> 6 overlap_? 3 <> 9 // Returns: ?(3 <> 6)
1 <> 3 overlap_? 6 <> 9 // Returns: \/
- Source
- __.scala