trampoline

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func More

func More()

Types

type Trampoline

type Trampoline[T any] interface {
	Get() T

	// Jump to next stage.
	Jump() Trampoline[T]

	Result() T

	// Complete checks if complete.
	Complete() bool

	Done() Trampoline[T]
}

Trampoline pattern allows to define recursive algorithms by iterative loop.

When get is called on the returned Trampoline, internally it will iterate calling ‘jump’ on the returned Trampoline as long as the concrete instance returned is more(Trampoline), stopping once the returned instance is done(Object).

Essential we convert looping via recursion into iteration, the key enabling mechanism is the fact that more(Trampoline) is a lazy operation.

T is type for returning result.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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