arraysslices

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

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEqual

func AssertEqual[T comparable](t *testing.T, got, want T)

func AssertNotEqual

func AssertNotEqual[T comparable](t *testing.T, got, want T)

func AssertTrue

func AssertTrue(t *testing.T, got bool)

func BalanceFor

func BalanceFor(transactions []Transaction, name string) float64

func Find

func Find[A any](items []A, predicate func(A) bool) (value A, found bool)

func Reduce

func Reduce[A, B any](collection []A, accumulator func(B, A) B, initialValue B) B

func Sum

func Sum(numbers []int) int

Sum calculates the total from a slice of numbers.

func SumAllTails

func SumAllTails(numbers ...[]int) []int

SumAllTails calculates the sums of all but the first number given a collection of slices.

Types

type Account

type Account struct {
	Name    string
	Balance float64
}

func NewBalanceFor

func NewBalanceFor(account Account, transactions []Transaction) Account

type Transaction

type Transaction struct {
	From string
	To   string
	Sum  float64
}

func NewTransaction

func NewTransaction(from, to Account, sum float64) Transaction

Jump to

Keyboard shortcuts

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