-
Notifications
You must be signed in to change notification settings - Fork 0
/
string.emu
121 lines (115 loc) · 1.42 KB
/
string.emu
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# (haystack needle)
def str-find
dup
num 1
ind
sto start-char
sto needle
len
swp
drop
dig
len
swp
drop
swp
sub
num 1
add
num 1 dup
bit
ct1
rcl start-char
str-char-find
dup
not
bco
ret
eco
swp
dig
rcl needle
swp
str-is-at
bco
swp
ret
eco
swp
drop
eit
num 0
def
# (haystack start character_needle) -> (haystack index)
def str-char-find
sto needle
dig
len
swp
drop
swp
num 1
bit
ct1
ind
rcl needle
equ
bco
ct1
ret
eco
eit
num 0
def
# (haystack needle location) -> (haystack boolean)
def str-is-at
num 1
sub
sto start
len
swp
sto needle
dig
len
swp
drop
swp
sub
rcl start
swp
grt
bco
num 0
ret
eco
rcl needle
len
swp
drop
num 1 dup
bit
ct1
rcl start
add
ind
rcl needle
ct1
ind
swp
drop
equ
not
bco
num 0
ret
eco
eit
num 1
def
# (subject start end) -> (subject substring)
#def str-substr
# swp
# num 1
# bit
# ct1
# ind