Range

package
v0.0.0-...-cfb4354 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2020 License: Zlib Imports: 7 Imported by: 0

Documentation

Overview

Package Range provides an efficient iterator over linear numeric sequences.

Index

Constants

View Source
const RangeTag = iolang.BasicTag("github.com/zephyrtronium/iolang/addons/range")

RangeTag is the Tag for Range objects.

Variables

This section is empty.

Functions

func At

func At(vm *VM, target, locals *Object, msg *Message) *Object

At is a Range method.

at returns the nth value of the range.

func Contains

func Contains(vm *VM, target, locals *Object, msg *Message) *Object

Contains is a Range method.

contains returns true if the given value occurs exactly in the range.

func First

func First(vm *VM, target, locals *Object, msg *Message) *Object

First is a Range method.

first moves the range's cursor to the beginning and returns its value.

func Foreach

func Foreach(vm *VM, target, locals *Object, msg *Message) (result *Object)

Foreach is a Range method.

foreach performs a loop for each element of the range.

func Index

func Index(vm *VM, target, locals *Object, msg *Message) *Object

Index is a Range method.

index returns the number of terms yielded from the range.

func IndexOf

func IndexOf(vm *VM, target, locals *Object, msg *Message) *Object

IndexOf is a Range method.

indexOf returns the index of the range that would produce a particular value, or nil if none would.

func IoAddon

func IoAddon() addon.Interface

IoAddon returns a loader for the Range addon.

func Last

func Last(vm *VM, target, locals *Object, msg *Message) *Object

Last is a Range method.

last moves the range's cursor to the end and returns its value.

func New

func New(vm *VM, start, stop, step float64) *Object

New creates a new Range object with the given start, stop, and step values.

func Next

func Next(vm *VM, target, locals *Object, msg *Message) *Object

Next is a Range method.

next increments the range's cursor. Returns self if the cursor is still in bounds and nil otherwise.

func Previous

func Previous(vm *VM, target, locals *Object, msg *Message) *Object

Previous is a Range method.

previous decrements the range's cursor. Returns self if the cursor is still in bounds and nil otherwise.

func Rewind

func Rewind(vm *VM, target, locals *Object, msg *Message) *Object

Rewind is a Range method.

rewind returns the range to its first value and returns the range.

func SetIndex

func SetIndex(vm *VM, target, locals *Object, msg *Message) *Object

SetIndex is a Range method.

setIndex seeks the range to a new index.

func SetRange

func SetRange(vm *VM, target, locals *Object, msg *Message) *Object

SetRange is a Range method.

setRange sets the range to have the given start, stop, and step values.

func Size

func Size(vm *VM, target, locals *Object, msg *Message) *Object

Size is a Range method.

size returns the number of steps the range can take.

func Value

func Value(vm *VM, target, locals *Object, msg *Message) *Object

Value is a Range method.

value returns the range's current value.

Types

type Range

type Range struct {
	Index, Last int64
	Start, Step float64
}

Range yields the terms of a linear sequence.

func With

func With(start, stop, step float64) Range

With creates a Range value with the given start, stop, and step values.

func (Range) Next

func (r Range) Next() (v float64, ok bool, s Range)

Next computes the current range value and increments the cursor. If the value is in the range, then ok is true. Returns the new range value.

func (Range) Previous

func (r Range) Previous() (v float64, ok bool, s Range)

Previous decrements the cursor and computes the range's new value. If the value is in the range, then ok is true. Returns the new range value.

func (Range) Value

func (r Range) Value() float64

Value returns the current value of the range. This succeeds regardless of whether the range cursor is in-bounds.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL