aboutsummaryrefslogtreecommitdiff
path: root/pkg/list/list.go
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-07-31 18:25:13 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-06 18:41:34 +0200
commit5f660b309bc695277c67223520499fcc13f3c59f (patch)
treece30f46d8feebac6eb3f5145e9c772be1c32f4ad /pkg/list/list.go
parent5168a9476f0e83264ecafc85bc9145e8bdcbb8dc (diff)
downloadlens-5f660b309bc695277c67223520499fcc13f3c59f.tar.gz
lens-5f660b309bc695277c67223520499fcc13f3c59f.tar.bz2
lens-5f660b309bc695277c67223520499fcc13f3c59f.zip
feat: Add album scanner
Diffstat (limited to 'pkg/list/list.go')
-rw-r--r--pkg/list/list.go25
1 files changed, 25 insertions, 0 deletions
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]
+ }
+}