64 lines
796 B
Go
64 lines
796 B
Go
package langext
|
|
|
|
func CompareIntArr(arr1 []int, arr2 []int) 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
|
|
}
|
|
|
|
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
|
|
}
|