aboutsummaryrefslogtreecommitdiff
path: root/pkg/u/list.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/u/list.go')
-rw-r--r--pkg/u/list.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/pkg/u/list.go b/pkg/u/list.go
index 7271ef3..39d7b11 100644
--- a/pkg/u/list.go
+++ b/pkg/u/list.go
@@ -16,12 +16,12 @@ func FirstOrZero[T any](v []T) T {
return v[0]
}
-func Map[T any, V any](ts []T, fun func(T) V) []V {
- rs := make([]V, len(ts))
- for i := range ts {
- rs[i] = fun(ts[i])
+func LastOrZero[T any](v []T) T {
+ if len(v) == 0 {
+ var zero T
+ return zero
}
- return rs
+ return v[len(v)-1]
}
func ChunkBy[T any](items []T, chunkSize int) [][]T {