aboutsummaryrefslogtreecommitdiffstats
path: root/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'util.go')
-rw-r--r--util.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/util.go b/util.go
new file mode 100644
index 0000000..c11ff40
--- /dev/null
+++ b/util.go
@@ -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:]...)
+}