Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 738 Bytes

File metadata and controls

37 lines (28 loc) · 738 Bytes

Range

A simple range library.

Basic use

use JonathanStarup.Range;

// print 0, 1, 2, .., 99
foreach (i <- Range.rangeExclusive(0, end = 100)) {
    println(i)
}

// print 0, 1, 2, .., 100
foreach (i <- Range.rangeInclusive(0, end = 100)) {
    println(i)
}

// print 0, -1, -2, .., -99
foreach (i <- Range.rangeExclusive(0, end = -100)) {
    println(i)
}

// print 0, 2, .., 100
foreach (i <- Range.rangeStepInclusive(0, end = 100, step = 2)) {
    println(i)
}

// print 0, -3, -6, -9
foreach (i <- Range.rangeStepInclusive(0, end = -9, step = -3)) {
    println(i)
}

// `map` converts the range any any collection with `Collectable` defined
let vector: Range.fromEndExclusive(42) |> Range.map(i -> "${i} is cool")