aboutsummaryrefslogtreecommitdiff
path: root/pkg/u/list.go
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-07-01 23:32:54 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-07-01 23:32:54 +0200
commit1b1460c8d4fa358433c51fd5293fd1c79f32aeff (patch)
treeb87528374798941a89e07ead5b92c2842deb40b6 /pkg/u/list.go
parent8f9853c8e26ffbad74e6414cec31104281a3860b (diff)
downloadcerrado-0.0.9.tar.gz
cerrado-0.0.9.tar.bz2
cerrado-0.0.9.zip
feat: Add pathing to the tree tabv0.0.9
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 {