ta0kira / zeolite

Zeolite is a statically-typed, general-purpose programming language.
Apache License 2.0
18 stars 0 forks source link

Add `Counter` functions with ranges and offsets. #201

Closed ta0kira closed 2 years ago

ta0kira commented 2 years ago

Right now it's too error-prone to use Counter.zeroIndexed to do ranges and offsets.

ta0kira commented 2 years ago

Rather than adding a bunch of named functions for different combinations, maybe it could use a builder, e.g.,

traverse (Counter.build().start(0).count(5).by(2) -> Int i) {
  // 0 2 4 6 8
}

traverse (Counter.build().start(10).finish(15) -> Int i) {
  // 10 11 12 13 14 15
}

traverse (Counter.build().count(n) -> Int i) {
  // same as Counter.zeroIndexed(n)
}

traverse (Counter.build().count(n).reverse() -> Int i) {
  // same as Counter.revZeroIndexed(n)
}