From 1b1460c8d4fa358433c51fd5293fd1c79f32aeff Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Mon, 1 Jul 2024 23:32:54 +0200 Subject: feat: Add pathing to the tree tab --- pkg/u/list.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'pkg/u/list.go') 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 { -- cgit v1.2.3