aboutsummaryrefslogtreecommitdiffstats
path: root/util.go
blob: c11ff40c869b7248418246d5de400f6e51906ef9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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:]...)
}