memoize

package module
v0.0.0-...-6fdb23a Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2015 License: MIT Imports: 2 Imported by: 2

README

memoize

Package memoize caches return values of functions.

Documentation

Overview

Package memoize caches return values of functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Memoize

func Memoize(fn interface{}) interface{}

Memoize takes a function and returns a function of the same type. The returned function remembers the return value(s) of the function call. Any pointer values will be used as an address, so functions that modify their arguments or programs that modify returned values will not work.

The returned function is safe to call from multiple goroutines if the original function is. Panics are handled, so calling panic from a function will call panic with the same value on future invocations with the same arguments.

The arguments to the function must be of comparable types. Slices, maps, functions, and structs or arrays that contain slices, maps, or functions cause a runtime panic if they are arguments to a memoized function. See also: https://golang.org/ref/spec#Comparison_operators

As a special case, variadic functions (func(x, y, ...z)) are allowed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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