numbers

package
v0.53.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 4 Imported by: 0

README

GoDoc Go Report Card

Package numbers provide functions for working with integer, float, slice of integers, and slice of floats.

Currently it have function to,

  • sort slice of floats using in-place mergesort algorithm
  • sort slice of integer/floats by predefined index
  • count number of value occurence in slice of integer/float
  • find minimum or maximum value in slice of integer/float
  • sum slice of integer/float

See documentation for more information.

Documentation

Overview

Package numbers provide miscellaneous functions for working with integer, float, slice of integer, and slice of floats.

Features

List of current features,

  • sort slice of floats using in-place mergesort algorithm.
  • sort slice of integer/floats by predefined index
  • count number of value occurrence in slice of integer/float
  • find minimum or maximum value in slice of integer/float
  • sum slice of integer/float

Index

Constants

View Source
const (
	// SortThreshold when the data less than SortThreshold, insertion sort
	// will be used to replace mergesort.
	SortThreshold = 7
)

Variables

This section is empty.

Functions

func Float64Round

func Float64Round(v float64, nprec int) float64

Float64Round will round `v` to `nprec` digit in fraction.

func Int64CreateSeq

func Int64CreateSeq(min, max int64) (seq []int64)

Int64CreateSeq will create and return sequence of integer from `min` to `max`.

E.g. if min is 0 and max is 5 then it will return `[0 1 2 3 4 5]`.

func IntCreateSeq

func IntCreateSeq(min, max int) (seq []int)

IntCreateSeq will create and return sequence of integer from `min` to `max`.

E.g. if min is 0 and max is 5 then it will return `[0 1 2 3 4 5]`.

func IntPickRandPositive

func IntPickRandPositive(maxVal int, dup bool, pickedListID, exsListID []int) (idx int)

IntPickRandPositive return random integer value from 0 to maximum value `maxVal`.

The random value is checked with already picked index: `pickedListID`.

If `dup` is true, allow duplicate value in `pickedListID`, otherwise only single unique value allowed in `pickedListID`.

If excluding index `exsListID` is not empty, do not pick the integer value listed in there.

Types

This section is empty.

Jump to

Keyboard shortcuts

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