aboutsummaryrefslogtreecommitdiff
path: root/lib/ints/ints.go
AgeCommit message (Collapse)Author
2024-12-29all: merge package "lib/ints" and "lib/ints64" into "slices"Shulhan
Now that Go has type parameter, we can use it to use the same function that accept different types for working with slice of int, int64.
2024-03-05all: comply with linter recommendations #2Shulhan
HTTP request now implicitly create request with context. Any false positive related to not closing HTTP response body has been annotated with "nolint:bodyclose". In the example code, use consistent "// Output:" comment format, by prefixing with single space. Any comment on code now also prefixing with single space. An error returned without variables now use [errors.New] instead of [fmt.Errorf]. Any error returned using [fmt.Errorf] now wrapped using "%w" instead of "%s". Also, replace error checking using [errors.Is] or [errors.As], instead of using equal/not-equal operator. Any statement like "x = x OP y" now replaced with "x OP= y". Also, swap statement is simplified using "x, y = y, x". Any switch statement with single case now replaced with if-condition. Any call to defer on function or program that call [os.Exit], now replaced by calling the deferred function directly. Any if-else condition now replaced with switch statement, if possible.
2024-01-24all: fix the warnings from linter reviveShulhan
This rename all variable "Ids" into "ListID".
2022-05-09all: reformat all codes using gofmt 1.19 (the Go tip)Shulhan
2020-05-16all: fix and suppress linter warningsShulhan
2019-10-21all: fix and add missing commentsShulhan
2019-09-24ints: add function to merge two slices of integers by distanceShulhan
MergeByDistance merge two slice of integers by their distance between each others. For example, if slice a contains "{1, 5, 9}" and b contains "{4, 11, 15}" and the distance is 3, the output of merged is "{1, 5, 9, 15}". The 4 and 11 are not included because 4 is in range between 1 and (1+3), and 11 is in range between 9 and 9+3.
2019-03-02ints: add function to remove value from sliceShulhan
The Remove function remove value "v" from slice if its exist and return new slice and true; otherwise, if not found, return unmodified slice and false.
2019-03-02numbers: move functions to process slices of int to package "ints"Shulhan
Just like package "bytes" or "strings", the package "ints" focus on slice of integer.