Code to get exe name for usage message

This commit is contained in:
Kovid Goyal
2022-09-21 07:59:07 +05:30
parent 2f83bbdc85
commit 8807f6d539
3 changed files with 39 additions and 6 deletions

23
tools/utils/misc.go Normal file
View File

@@ -0,0 +1,23 @@
// License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
package utils
import (
"fmt"
)
var _ = fmt.Print
func Reverse[T any](s []T) {
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
s[i], s[j] = s[j], s[i]
}
}
func Reversed[T any](s []T) []T {
ans := make([]T, len(s))
for i, x := range s {
ans[len(s)-1-i] = x
}
return ans
}