-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstdlib.shin
More file actions
53 lines (40 loc) · 972 Bytes
/
stdlib.shin
File metadata and controls
53 lines (40 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
VAR private_string_ascii = "翿翿翿翿翿翿翿翿翿\t\n翿翿翿翿翿翿翿翿翿翿翿翿翿翿翿翿翿翿翿翿翿 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~翿"
FUN string_concat(str, suffix)
RETURN str + suffix
END
FUN string_charAt(str, idx)
RETURN str / idx
END
FUN string_charCodeAt(str, idx)
VAR char = string_charAt(str, idx)
FOR i = 0 TO LEN(private_string_ascii) THEN
IF char == private_string_ascii/i THEN
RETURN i
END
END
RETURN -1
END
FUN string_split(str)
VAR list = []
FOR i = 0 TO LEN(str) THEN
APPEND(list, str/i)
END
RETURN list
END
FUN string_indexOf(str, char)
FOR i = 0 TO LEN(str) THEN
IF str/i == char THEN
RETURN i
END
END
RETURN -1
END
FUN string_lastIndexOf(str, char)
FOR i = LEN(str)-1 TO -1 STEP -1 THEN
IF str/i == char THEN
RETURN i
END
END
RETURN -1
END
PRINT("string loaded"); RETURN 0