From 5f660b309bc695277c67223520499fcc13f3c59f Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Mon, 31 Jul 2023 18:25:13 +0200 Subject: feat: Add album scanner --- pkg/list/list.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'pkg/list/list.go') diff --git a/pkg/list/list.go b/pkg/list/list.go index ff259f7..dfc3fb7 100644 --- a/pkg/list/list.go +++ b/pkg/list/list.go @@ -7,3 +7,28 @@ func Map[V any, T any](source []V, fun func(V) T) []T { } return result } + +type Pair[T, U any] struct { + Left T + Right U +} + +func Zip[T, U any](left []T, right []U) []Pair[T, U] { + // pick the array with the smaller length + l := len(left) + if len(left) > len(right) { + l = len(right) + } + + pairs := make([]Pair[T, U], len(left)) + for i := 0; i < l; i++ { + pairs[i] = Pair[T, U]{left[i], right[i]} + } + return pairs +} + +func Revert[T any](s []T) { + for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { + s[i], s[j] = s[j], s[i] + } +} -- cgit v1.2.3