Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New is the Range constructor.
It yields a Result whose payload is a Range over [begin, end] with a step of 1 and an inclusive end. The end can be excluded with Exclusive() and the step set with WithStep(). A zero step is invalid and produces a Result carrying an Error ("step cannot be zero") instead of a payload — construction never panics and never returns nil.
r1 := Range.New(1, 5) // 1..5 step 1 r2 := Range.New(1, 5, Range.Exclusive()) // 1...5 r3 := Range.New(0, 10, Range.WithStep(2)) // 0,2,4,6,8,10
Types ¶
type Interface ¶
type Interface interface {
Begin() Number.Interface
End() Number.Interface
Step() Number.Interface
ExcludesEnd() bool
Includes(n int64) bool
Len() int
IsEmpty() bool
Each(fn func(Number.Interface) Result.Interface) Result.Interface
ToArray() Array.Interface
IsNull() bool
}
Range is a numeric interval composite over Go int64 bounds.
Modelled on Ruby's Range, it supports both an inclusive end (Ruby's "1..5") and an exclusive end (Ruby's "1...5"), and a non-zero integer step. Its fallible construction returns a Result.Interface so an invalid step (zero) is a value rather than a panic. The elements it exposes are go-composites Numbers.
Note: Range is deliberately integer-only — its bounds and step are Go int64 values — which keeps element enumeration and coverage tractable.