initial commit

This commit is contained in:
2025-12-31 15:33:16 -05:00
commit 89f2114b06
51 changed files with 4779 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
package values
// FirstNonZero will return the first non zero value. If none exists,
// it returns the zero value.
func FirstNonZero[T comparable](vals ...T) T {
var zeroT T
for _, v := range vals {
if v != zeroT {
return v
}
}
return zeroT
}
// CountNonZero returns the count of items that are non zero
func CountNonZero[T comparable](vals ...T) (count int) {
var zeroT T
for _, v := range vals {
if v != zeroT {
count++
}
}
return count
}