num

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Conform

func Conform[A comparable, CA Class[A]](c CA) func(t *testing.T, x, y, z A)

Conform returns a function testing if the implementation abides by its laws.

Types

type Class

type Class[A any] interface {
	Add(A, A) A
	Sub(A, A) A
	Mul(A, A) A

	Negate(A) A
	Abs(A) A
	SigNum(A) A
}

type Numeric

type Numeric interface {
	constraints.Integer | constraints.Float
}

type Type

type Type[A Numeric] struct{}

func NewType

func NewType[A Numeric]() Type[A]
Example
package main

import (
	"fmt"

	"github.com/calebcase/base/num"
)

func main() {
	t := num.NewType[int]()

	fmt.Println(t.Add(5, 6))

}
Output:

11

func (Type[A]) Abs

func (t Type[A]) Abs(x A) A

func (Type[A]) Add

func (t Type[A]) Add(x, y A) A

func (Type[A]) Mul

func (t Type[A]) Mul(x, y A) A

func (Type[A]) Negate

func (t Type[A]) Negate(x A) A

func (Type[A]) SigNum

func (t Type[A]) SigNum(x A) A

func (Type[A]) Sub

func (t Type[A]) Sub(x, y A) A

Jump to

Keyboard shortcuts

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