funcs

package
v0.0.0-...-434faa1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FactorialSelfApply = YRecurse(newFactorialFunc)

Functions

func FactorialCall

func FactorialCall(n int) any

func FactorialFunc

func FactorialFunc(n int) any

Factorial is a function that computes the factorial of n using the Y combinator

func IterFactorial

func IterFactorial(n int) any

func StructFactorial

func StructFactorial(n int) any

func StructFactorialInt64

func StructFactorialInt64(n int) any

Types

type FactorialImplementer

type FactorialImplementer struct{}

Factorial function implementation

func (FactorialImplementer) Func

func (f FactorialImplementer) Func(g Func, n int) int

type Fii

type Fii func(n int) *big.Int

type Fn

type Fn func(Fn, int64) int64

Func is a type representing a function that can compute a factorial

func YFn

func YFn(f Fn) Fn

Y is a function that takes a function f and returns a function that computes factorial

type FnInt64

type FnInt64 func(int64) int64

FnInt64 is a specific type of recursive function that implements some data logic and decides when to recursively call itself. However, it does not have a direct reference to itself but must use a function pointer from a closure or variable.

func YRecurse

func YRecurse(newFunc YFuncGenerator) FnInt64

YRecurse create a new function for every iteration and then calls this function.

type Func

type Func interface {
	Func(Func, int) int
}

Unified function interface

func Y

func Y(f Func) Func

Y combinator function

type FuncImpl

type FuncImpl func(Func, int) int

FuncImpl to convert a function to the Func interface

func (FuncImpl) Func

func (f FuncImpl) Func(g Func, n int) int

type YFuncGenerator

type YFuncGenerator func(FnInt64) FnInt64

YFuncGenerator is a function that takes a FnInt64 function returns a function to call the given FnInt64 recursively.

Jump to

Keyboard shortcuts

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