diff options
| author | sam-anthony <samanthony6@protonmail.com> | 2022-03-31 20:27:39 -0230 |
|---|---|---|
| committer | sam-anthony <samanthony6@protonmail.com> | 2022-03-31 20:27:39 -0230 |
| commit | 6634b3ff6bcdffbab38a049460ae6ea3cd68944f (patch) | |
| tree | 4cbcb7829060883afe074854a2ffc82b4ab2e31b /util | |
| parent | cc0d171c5cd1057693960b7f63aee29e7f70ee8e (diff) | |
| download | volute-6634b3ff6bcdffbab38a049460ae6ea3cd68944f.zip | |
refactor and compressor map image widget
Diffstat (limited to 'util')
| -rw-r--r-- | util/util.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/util/util.go b/util/util.go new file mode 100644 index 0000000..5812ee1 --- /dev/null +++ b/util/util.go @@ -0,0 +1,31 @@ +package util + +import ( + "fmt" + "os" + + "github.com/sam-anthony/volute/mass" + "github.com/sam-anthony/volute/pressure" + "github.com/sam-anthony/volute/temperature" +) + +func Check(err error) { + if err != nil { + fmt.Println(err) + os.Exit(1) + } +} + +func Insert[T int32 | float32 | temperature.Temperature | pressure.Pressure | mass.FlowRate](slice []T, elem T, i int) []T { + return append( + slice[:i], + append( + []T{elem}, + slice[i:]..., + )..., + ) +} + +func Remove[T int32 | float32 | temperature.Temperature | pressure.Pressure | mass.FlowRate](slice []T, i int) []T { + return append(slice[:i], slice[i+1:]...) +} |