Compare commits

...

3 Commits

Author SHA1 Message Date
efc99a9658 Ref implemented 2025-02-04 22:04:55 +01:00
7988676059 updated dependencies 2025-02-01 19:43:09 +01:00
3901e3934f Update go.mod 2024-12-16 19:45:01 +01:00
4 changed files with 15 additions and 5 deletions

4
go.mod
View File

@ -1,5 +1,5 @@
module git.milar.in/milarin/slices
module git.tordarus.net/tordarus/slices
go 1.19
require git.milar.in/milarin/gmath v0.0.3
require git.tordarus.net/tordarus/gmath v0.0.7

4
go.sum
View File

@ -1,2 +1,2 @@
git.milar.in/milarin/gmath v0.0.3 h1:ii6rKNItS55O/wtIFhD1cTN2BMwDZjTBmiOocKURvxM=
git.milar.in/milarin/gmath v0.0.3/go.mod h1:HDLftG5RLpiNGKiIWh+O2G1PYkNzyLDADO8Cd/1abiE=
git.tordarus.net/tordarus/gmath v0.0.7 h1:tR48idt9AUL0r556ww3ZxByTKJEr6NWCTlhl2ihzYxQ=
git.tordarus.net/tordarus/gmath v0.0.7/go.mod h1:mO7aPlvNrGVE9UFXEuuACjZgMDsM63l3OcQy6xSQnoE=

View File

@ -1,6 +1,6 @@
package slices
import "git.milar.in/milarin/gmath"
import "git.tordarus.net/tordarus/gmath"
func Reduce[T, R any](slice []T, reducer func(current R, v T) R) R {
res := new(R)

10
to.go
View File

@ -17,6 +17,16 @@ func Deref[T any](s []*T) []T {
return out
}
// Ref returns a slice containing pointers to all values of s.
// The order in s is preserved.
func Ref[T any](s []T) []*T {
out := make([]*T, 0, len(s))
Each(s, func(v T) {
out = append(out, &v)
})
return out
}
// ToList returns a list.List containing all values of s
func ToList[T any](s []T) *list.List {
l := list.New()