diff --git a/langext/compare.go b/langext/compare.go index ac35b85..5573f5d 100644 --- a/langext/compare.go +++ b/langext/compare.go @@ -30,3 +30,34 @@ func CompareIntArr(arr1 []int, arr2 []int) bool { return false } + +func CompareArr[T OrderedConstraint](arr1 []T, arr2 []T) bool { + + for i := 0; i < len(arr1) || i < len(arr2); i++ { + + if i < len(arr1) && i < len(arr2) { + + if arr1[i] < arr2[i] { + return true + } else if arr1[i] > arr2[i] { + return false + } else { + continue + } + + } + + if i < len(arr1) { + + return true + + } else { // if i < len(arr2) + + return false + + } + + } + + return false +} diff --git a/langext/coords.go b/langext/coords.go new file mode 100644 index 0000000..38ed6d7 --- /dev/null +++ b/langext/coords.go @@ -0,0 +1,11 @@ +package langext + +import "math" + +func DegToRad(deg float64) float64 { + return deg * (math.Pi / 180.0) +} + +func RadToDeg(rad float64) float64 { + return rad / (math.Pi * 180.0) +}