diff options
| author | sam-anthony <samanthony6@protonmail.com> | 2022-03-27 21:31:39 -0230 |
|---|---|---|
| committer | sam-anthony <samanthony6@protonmail.com> | 2022-03-27 21:31:39 -0230 |
| commit | cc0d171c5cd1057693960b7f63aee29e7f70ee8e (patch) | |
| tree | de520f33eb639da17f19bbd15110aa56d501c2b6 /util.go | |
| parent | 5bb9043aea41498c886aabdc7f1a32e40011dc4a (diff) | |
| download | volute-cc0d171c5cd1057693960b7f63aee29e7f70ee8e.zip | |
variable number of datapoints
Diffstat (limited to 'util.go')
| -rw-r--r-- | util.go | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "os" +) + +func check(err error) { + if err != nil { + fmt.Println(err) + os.Exit(1) + } +} + +func insert[T int32 | float32 | temperature | pressure | massFlowRate](slice []T, elem T, i int) []T { + return append( + slice[:i], + append( + []T{elem}, + slice[i:]..., + )..., + ) +} + +func remove[T int32 | float32 | temperature | pressure | massFlowRate](slice []T, i int) []T { + return append(slice[:i], slice[i+1:]...) +} |