diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2026-02-10 16:56:06 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2026-02-10 16:56:06 -0500 |
| commit | 430f97bed9d758de90a72b0c06b2be1989ba2b1d (patch) | |
| tree | 057a578389bfafe595ba415797908979c3d09add /layout/math.go | |
| parent | 3ce04a4d3dc8d174b520d85804e5c8dce8c5d08f (diff) | |
| download | gui-430f97bed9d758de90a72b0c06b2be1989ba2b1d.zip | |
add rows layout
Diffstat (limited to 'layout/math.go')
| -rw-r--r-- | layout/math.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/layout/math.go b/layout/math.go new file mode 100644 index 0000000..f09cf00 --- /dev/null +++ b/layout/math.go @@ -0,0 +1,33 @@ +package layout + +type number interface { + complex | float | integer +} + +type complex interface { + ~complex64 | ~complex128 +} + +type float interface { + ~float32 | ~float64 +} + +type integer interface { + signed | unsigned +} + +type signed interface { + ~int | ~int8 | ~int16 | ~int32 | ~int64 +} + +type unsigned interface { + ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 +} + +func sum[N number](ns []N) N { + var n N + for i := range ns { + n += ns[i] + } + return n +} |