Skip to content

Commit 6dca1e2

Browse files
committed
Useful slices for cartasian product
1 parent 4329f7c commit 6dca1e2

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

string.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package iterium
2+
3+
// concatMultipleSlices merge more than two slices at once.
4+
func concatMultipleSlices[T any](slices ...[]T) (result []T) {
5+
for _, s := range slices {
6+
result = append(result, s...)
7+
}
8+
9+
return result
10+
}
11+
12+
// AsciiLowercase represents lower case letters.
13+
var AsciiLowercase = []string{
14+
"a", "b", "c", "d", "e", "f", "g",
15+
"h", "i", "j", "k", "l", "m", "n",
16+
"o", "p", "q", "r", "s", "t", "u",
17+
"v", "w", "x", "y", "z",
18+
}
19+
20+
// AsciiUppercase represents upper case letters.
21+
var AsciiUppercase = []string{
22+
"A", "B", "C", "D", "E", "F", "G",
23+
"H", "I", "J", "K", "L", "M", "N",
24+
"O", "P", "Q", "R", "S", "T", "U",
25+
"V", "W", "X", "Y", "Z",
26+
}
27+
28+
// AsciiLetters is a concatenation of AsciiLowercase and AsciiUppercase.
29+
var AsciiLetters = append(AsciiLowercase, AsciiUppercase...)
30+
31+
// Digits is a slice of the digits in the string type.
32+
var Digits = []string{
33+
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
34+
}
35+
36+
// HexDigits represents hexadecimal letters.
37+
var HexDigits = []string{
38+
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
39+
"a", "b", "c", "d", "e", "f", "A", "B", "C", "D",
40+
"E", "F",
41+
}
42+
43+
// OctDigits represents octadecimal letters.
44+
var OctDigits = []string{
45+
"0", "1", "2", "3", "4", "5", "6", "7",
46+
}
47+
48+
// Punctuation is a slice of ASCII characters that
49+
// are considered punctuation marks in the C locale
50+
var Punctuation = []string{
51+
"!", "\"", "#", "$", "%", "&", "'", "(",
52+
")", "*", "+", ",", "-", ".", "/", ":",
53+
";", "<", "=", ">", "?", "@", "[", "\\",
54+
"]", "^", "_", "`", "{", "|", "}", "~",
55+
}
56+
57+
// Whitespace contains all ASCII characters that are considered whitespace
58+
var Whitespace = []string{
59+
" ", "\t", "\n", "\r", "\x0b", "\x0c",
60+
}
61+
62+
// Printable is a slice of ASCII characters which are considered printable.
63+
var Printable = concatMultipleSlices(
64+
AsciiLetters, Digits, Punctuation, Whitespace,
65+
)

0 commit comments

Comments
 (0)