Range

object Range
Companion
class
trait Product
trait Mirror
class Object
trait Matchable
class Any

Type members

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Inherited from
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Inherited from
Mirror

Value members

Concrete methods

def atLeast[A](n: Int, l: List[A]): Boolean

Check that list contains at least a certain number of elements.

Check that list contains at least a certain number of elements.

def clamp[A](x: A, y: A, n: A)(O: Ordering[A]): A

Truncate a value so it stays within some range.

Truncate a value so it stays within some range.

scala> clamp(5, 10, 15)
10

scala> clamp(5, 10, 0)
5
def constant[A](x: A, y: A): Range[A]

Construct a range which is unaffected by the size parameter.

Construct a range which is unaffected by the size parameter.

A range from 0 to 10, with the origin at 0:

scala> Range.constant(0, 10).bounds(x)
(0,10)

scala> Range.constant(0, 10).origin
0
def constantFrom[A](z: A, x: A, y: A): Range[A]

Construct a range which is unaffected by the size parameter with a origin point which may differ from the bounds.

Construct a range which is unaffected by the size parameter with a origin point which may differ from the bounds.

A range from -10 to 10, with the origin at 0:

scala> Range.constantFrom(0, -10, 10).bounds(x)
(-10,10)

scala> Range.constantFrom(0, -10, 10).origin
0

A range from 1970 to 2100, with the origin at 2000:

scala> Range.constantFrom(2000, 1970, 2100).bounds(x)
(1970,2100)

scala> Range.constantFrom(2000, 1970, 2100).origin
2000
def linear[A](x: A, y: A)(`evidence$1`: Integral[A], `evidence$2`: IntegralPlus[A], `evidence$3`: NumericPlus[A]): Range[A]

Construct a range which scales the second bound relative to the size parameter.

Construct a range which scales the second bound relative to the size parameter.

scala> Range.linear(0, 10).bounds(Size(1))
(0,0)

scala> Range.linear(0, 10).bounds(Size(50))
(0,5)

scala> Range.linear(0, 10).bounds(Size(100))
(0,10)
def linearFrac[A](x: A, y: A)(`evidence$6`: Fractional[A], `evidence$7`: DecimalPlus[A], `evidence$8`: NumericPlus[A]): Range[A]

Construct a range which scales the second bound relative to the size parameter.

Construct a range which scales the second bound relative to the size parameter.

This works the same as 'linear', but for fractional values.

def linearFracFrom[A](z: A, x: A, y: A)(I: Fractional[A], J: DecimalPlus[A], R: NumericPlus[A]): Range[A]

Construct a range which scales the bounds relative to the size parameter.

Construct a range which scales the bounds relative to the size parameter.

This works the same as linearFrom, but for fractional values.

def linearFracFrom_[A](z: A, x: A, y: A)(`evidence$9`: Fractional[A], `evidence$10`: NumericPlus[A]): Range[A]
def linearFrom[A](z: A, x: A, y: A)(I: Integral[A], J: IntegralPlus[A], R: NumericPlus[A]): Range[A]

Construct a range which scales the second bound relative to the size parameter.

Construct a range which scales the second bound relative to the size parameter.

scala> Range.linearFrom(0, -10, 10).bounds(Size(1))
(0,0)

scala> Range.linearFrom(0, -10, 20).bounds(Size(50))
(-5,10)

scala> Range.linearFrom(0, -10, 20).bounds(Size(100))
(-10,20)
def linearFrom_[A](z: A, x: A, y: A)(`evidence$4`: Integral[A], `evidence$5`: NumericPlus[A]): Range[A]
def scaleLinear[A](sz: Size, z: A, n: A)(I: Integral[A], J: NumericPlus[A]): A

Scale an integral linearly with the size parameter.

Scale an integral linearly with the size parameter.

def scaleLinearFrac[A](sz: Size, z: A, n: A)(F: Fractional[A], J: NumericPlus[A]): A

Scale a fractional number linearly with the size parameter.

Scale a fractional number linearly with the size parameter.

def singleton[A](x: A): Range[A]

Construct a range which represents a constant single value.

Construct a range which represents a constant single value.

scala> Range.singleton(5).bounds(x)
(5,5)

scala> Range.singleton(5).origin
5