stats

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package stats contains statistical functions such as Sum.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sum

func Sum[V cmp.Ordered](items []V) V

Sum calculates the sum of a slice of ordered numeric values.

It iterates over the slice and accumulates the total sum.

Example
package main

import (
	"fmt"

	"github.com/xuender/flow/stats"
)

func main() {
	fmt.Println(stats.Sum([]int{1, 2, 3, 4, 5}))
	fmt.Println(stats.Sum([]string{"a", "b", "c"}))

}
Output:

15
abc

Types

type Number

type Number interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
		~float32 | ~float64
}

Number defines a type constraint for numeric types.

It includes all integer, unsigned integer, and floating-point types.

Jump to

Keyboard shortcuts

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