Skip to content

melon.iter

garryspins edited this page Feb 27, 2026 · 5 revisions

melon.iter


shared link

Contains functions relating to custom iterators
melon

Functions

melon.iter.Break

shared link
melon.iter.Break()
Breaks the current iter Only to be called inside a melon.iter.NewIter wrapped iterator

melon.iter.GetState

shared link
melon.iter.GetState(lvl: number) -> table?

Argument and Return information

Arguments

# Name Type Description
1 lvl number How many levels down from the top should we go

Returns

# Name Type Description
1 table table The state from the stack if it was found

Gets a stack state from the given level, providing 0 gives you the Top

melon.iter.Goto

shared link
melon.iter.Goto(i: number, lvl: number)

Argument and Return information

Arguments

# Name Type Description
1 i number The index to jump to
2 lvl number How many levels down in the stack should be run this on
Jumps to the given index in the active iterator Only to be called inside a melon.iter.NewIter wrapped iterator

melon.iter.NewIter

shared link
melon.iter.NewIter(input: fn) -> fn

Argument and Return information

Arguments

# Name Type Description
1 input fn The iterator function

Returns

# Name Type Description
1 fn fn The wrapped iterator function
Wraps the input iterator function to allow for melon.iter.* functions to work This is only designed for non state-altering iterators that are number indexed

melon.iter.Next

shared link
melon.iter.Next(offset?: number) -> any?

Argument and Return information

Arguments

# Name Type Description
1 offset? number The amount to add to the current index

Returns

# Name Type Description
1 any any The next value in the iterator

Returns the next value in the iterator

melon.iter.ReverseArgs

shared link
melon.iter.ReverseArgs(any...) -> any...

Argument and Return information

Arguments

# Name Type Description
1 any any... Args to reverse

Returns

# Name Type Description
1 any any... Reversed arguments

Reverses the given arguments

melon.iter.SetOverflowProtect

shared link
melon.iter.SetOverflowProtect(number)

Argument and Return information

Arguments

# Name Type Description
1 number number How many iterations before [melon.iter.NewIter] iterators error out

Sets the number of iterations before all iterators cancel

melon.iter.Skip

shared link
melon.iter.Skip(i: number, lvl: number)

Argument and Return information

Arguments

# Name Type Description
1 i number How many indices to skip
2 lvl number How many levels down in the stack should be run this on
Skips the given number of indices into the future of the iterator Only to be called inside a melon.iter.NewIter wrapped iterator

melon.iter.Top

shared link
melon.iter.Top() -> table

Argument and Return information

Returns

# Name Type Description
1 table table Stack state

Returns the top of the current iterator stack

Clone this wiki locally