Examine individual changes
This page allows you to examine the variables generated by the Abuse Filter for an individual change.
Variables generated for this change
Variable | Value |
---|---|
Edit count of the user (user_editcount) | 213 |
Name of the user account (user_name) | 'Stkptr' |
Age of the user account (user_age) | 60282069 |
Page ID (page_id) | 0 |
Page namespace (page_namespace) | 0 |
Page title (without namespace) (page_title) | '◧◨/Interpreter' |
Full page title (page_prefixedtitle) | '◧◨/Interpreter' |
Action (action) | 'edit' |
Edit summary/reason (summary) | 'Add an interpreter' |
Old content model (old_content_model) | '' |
New content model (new_content_model) | 'wikitext' |
Old page wikitext, before the edit (old_wikitext) | '' |
New page wikitext, after the edit (new_wikitext) | '== Python (by [[User:stkptr|stkptr]]) ==
<pre>
import math
import sys
# https://esolangs.org/wiki/%E2%97%A7%E2%97%A8
LEFT = "◧"
RIGHT = "◨"
# This assumes that the source does not have arbitrary other symbols in it
# Files with characters inside commands will not be parsed correctly
# Invalid programs are also not explicitly tested for
def parse(source):
index = 0
parsed = []
def get(i):
if i < len(source):
return source[i]
while index < len(source):
if source[index] == LEFT:
index += 2
n = 0
while get(index) == RIGHT:
index += 1
n += 1
# overstep
if get(index) == LEFT and get(index + 1) == RIGHT:
index -= 1
n -= 1
parsed.append((-1)**n * math.ceil(n / 2))
elif source[index] == RIGHT:
index += 3
parsed.append(None)
else:
index += 1
return parsed
class BoundedTape:
def __init__(self, default=0):
self.cells = []
self.default = default
def __getitem__(self, index):
if index >= len(self.cells):
return self.default
return self.cells[index]
def __setitem__(self, index, value):
extra = index + 1 - len(self.cells)
if extra > 0:
self.cells += [self.default] * extra
self.cells[index] = value
class Tape:
def __init__(self, default=0):
self.left = BoundedTape(default)
self.right = BoundedTape(default)
def __getitem__(self, index):
if index < 0:
return self.left[abs(index) - 1]
return self.right[index]
def __setitem__(self, index, value):
if index < 0:
self.left[abs(index) - 1] = value
else:
self.right[index] = value
class Machine:
def __init__(self, program):
self.tape = Tape(False)
self.pointer = 0
self.ip = 0
self.program = program
def step(self):
if self.ip >= len(self.program):
return False
if self.program[self.ip] is None:
self.tape[self.pointer] = not self.tape[self.pointer]
self.pointer += 1
self.ip += 1
else:
jump = self.program[self.ip] if self.tape[self.pointer] else 1
self.pointer -= 1
self.ip += jump
return True
def run(self):
running = True
while running:
running = self.step()
def run_source(source):
program = parse(source)
machine = Machine(program)
machine.run()
return machine
def main():
if len(sys.argv) != 2:
print("You must pass a single source filename")
return
with open(sys.argv[1]) as f:
source = f.read()
machine = run_source(source)
touched = len(machine.tape.left.cells) + len(machine.tape.right.cells)
print(f"Program ended with machine altering at most {touched} cell(s)")
print(f"Final tape pointer was {machine.pointer}")
if __name__ == "__main__":
main()
</pre>' |
Unified diff of changes made by edit (edit_diff) | '@@ -1,0 +1,131 @@
+== Python (by [[User:stkptr|stkptr]]) ==
+
+<pre>
+import math
+import sys
+
+
+# https://esolangs.org/wiki/%E2%97%A7%E2%97%A8
+
+
+LEFT = "◧"
+RIGHT = "◨"
+
+
+# This assumes that the source does not have arbitrary other symbols in it
+# Files with characters inside commands will not be parsed correctly
+# Invalid programs are also not explicitly tested for
+def parse(source):
+ index = 0
+ parsed = []
+
+ def get(i):
+ if i < len(source):
+ return source[i]
+
+ while index < len(source):
+ if source[index] == LEFT:
+ index += 2
+ n = 0
+ while get(index) == RIGHT:
+ index += 1
+ n += 1
+ # overstep
+ if get(index) == LEFT and get(index + 1) == RIGHT:
+ index -= 1
+ n -= 1
+ parsed.append((-1)**n * math.ceil(n / 2))
+ elif source[index] == RIGHT:
+ index += 3
+ parsed.append(None)
+ else:
+ index += 1
+
+ return parsed
+
+
+class BoundedTape:
+ def __init__(self, default=0):
+ self.cells = []
+ self.default = default
+
+ def __getitem__(self, index):
+ if index >= len(self.cells):
+ return self.default
+ return self.cells[index]
+
+ def __setitem__(self, index, value):
+ extra = index + 1 - len(self.cells)
+ if extra > 0:
+ self.cells += [self.default] * extra
+ self.cells[index] = value
+
+
+class Tape:
+ def __init__(self, default=0):
+ self.left = BoundedTape(default)
+ self.right = BoundedTape(default)
+
+ def __getitem__(self, index):
+ if index < 0:
+ return self.left[abs(index) - 1]
+ return self.right[index]
+
+ def __setitem__(self, index, value):
+ if index < 0:
+ self.left[abs(index) - 1] = value
+ else:
+ self.right[index] = value
+
+
+class Machine:
+ def __init__(self, program):
+ self.tape = Tape(False)
+ self.pointer = 0
+ self.ip = 0
+ self.program = program
+
+ def step(self):
+ if self.ip >= len(self.program):
+ return False
+ if self.program[self.ip] is None:
+ self.tape[self.pointer] = not self.tape[self.pointer]
+ self.pointer += 1
+ self.ip += 1
+ else:
+ jump = self.program[self.ip] if self.tape[self.pointer] else 1
+ self.pointer -= 1
+ self.ip += jump
+ return True
+
+ def run(self):
+ running = True
+ while running:
+ running = self.step()
+
+
+def run_source(source):
+ program = parse(source)
+ machine = Machine(program)
+ machine.run()
+ return machine
+
+
+def main():
+ if len(sys.argv) != 2:
+ print("You must pass a single source filename")
+ return
+
+ with open(sys.argv[1]) as f:
+ source = f.read()
+
+ machine = run_source(source)
+ touched = len(machine.tape.left.cells) + len(machine.tape.right.cells)
+ print(f"Program ended with machine altering at most {touched} cell(s)")
+ print(f"Final tape pointer was {machine.pointer}")
+
+
+if __name__ == "__main__":
+ main()
+
+</pre>
' |
New page size (new_size) | 3130 |
Old page size (old_size) | 0 |
Lines added in edit (added_lines) | [
0 => '== Python (by [[User:stkptr|stkptr]]) ==',
1 => '',
2 => '<pre>',
3 => 'import math',
4 => 'import sys',
5 => '',
6 => '',
7 => '# https://esolangs.org/wiki/%E2%97%A7%E2%97%A8',
8 => '',
9 => '',
10 => 'LEFT = "◧"',
11 => 'RIGHT = "◨"',
12 => '',
13 => '',
14 => '# This assumes that the source does not have arbitrary other symbols in it',
15 => '# Files with characters inside commands will not be parsed correctly',
16 => '# Invalid programs are also not explicitly tested for',
17 => 'def parse(source):',
18 => ' index = 0',
19 => ' parsed = []',
20 => '',
21 => ' def get(i):',
22 => ' if i < len(source):',
23 => ' return source[i]',
24 => '',
25 => ' while index < len(source):',
26 => ' if source[index] == LEFT:',
27 => ' index += 2',
28 => ' n = 0',
29 => ' while get(index) == RIGHT:',
30 => ' index += 1',
31 => ' n += 1',
32 => ' # overstep',
33 => ' if get(index) == LEFT and get(index + 1) == RIGHT:',
34 => ' index -= 1',
35 => ' n -= 1',
36 => ' parsed.append((-1)**n * math.ceil(n / 2))',
37 => ' elif source[index] == RIGHT:',
38 => ' index += 3',
39 => ' parsed.append(None)',
40 => ' else:',
41 => ' index += 1',
42 => '',
43 => ' return parsed',
44 => '',
45 => '',
46 => 'class BoundedTape:',
47 => ' def __init__(self, default=0):',
48 => ' self.cells = []',
49 => ' self.default = default',
50 => '',
51 => ' def __getitem__(self, index):',
52 => ' if index >= len(self.cells):',
53 => ' return self.default',
54 => ' return self.cells[index]',
55 => '',
56 => ' def __setitem__(self, index, value):',
57 => ' extra = index + 1 - len(self.cells)',
58 => ' if extra > 0:',
59 => ' self.cells += [self.default] * extra',
60 => ' self.cells[index] = value',
61 => '',
62 => '',
63 => 'class Tape:',
64 => ' def __init__(self, default=0):',
65 => ' self.left = BoundedTape(default)',
66 => ' self.right = BoundedTape(default)',
67 => '',
68 => ' def __getitem__(self, index):',
69 => ' if index < 0:',
70 => ' return self.left[abs(index) - 1]',
71 => ' return self.right[index]',
72 => '',
73 => ' def __setitem__(self, index, value):',
74 => ' if index < 0:',
75 => ' self.left[abs(index) - 1] = value',
76 => ' else:',
77 => ' self.right[index] = value',
78 => '',
79 => '',
80 => 'class Machine:',
81 => ' def __init__(self, program):',
82 => ' self.tape = Tape(False)',
83 => ' self.pointer = 0',
84 => ' self.ip = 0',
85 => ' self.program = program',
86 => '',
87 => ' def step(self):',
88 => ' if self.ip >= len(self.program):',
89 => ' return False',
90 => ' if self.program[self.ip] is None:',
91 => ' self.tape[self.pointer] = not self.tape[self.pointer]',
92 => ' self.pointer += 1',
93 => ' self.ip += 1',
94 => ' else:',
95 => ' jump = self.program[self.ip] if self.tape[self.pointer] else 1',
96 => ' self.pointer -= 1',
97 => ' self.ip += jump',
98 => ' return True',
99 => '',
100 => ' def run(self):',
101 => ' running = True',
102 => ' while running:',
103 => ' running = self.step()',
104 => '',
105 => '',
106 => 'def run_source(source):',
107 => ' program = parse(source)',
108 => ' machine = Machine(program)',
109 => ' machine.run()',
110 => ' return machine',
111 => '',
112 => '',
113 => 'def main():',
114 => ' if len(sys.argv) != 2:',
115 => ' print("You must pass a single source filename")',
116 => ' return',
117 => '',
118 => ' with open(sys.argv[1]) as f:',
119 => ' source = f.read()',
120 => '',
121 => ' machine = run_source(source)',
122 => ' touched = len(machine.tape.left.cells) + len(machine.tape.right.cells)',
123 => ' print(f"Program ended with machine altering at most {touched} cell(s)")',
124 => ' print(f"Final tape pointer was {machine.pointer}")',
125 => '',
126 => '',
127 => 'if __name__ == "__main__":',
128 => ' main()',
129 => '',
130 => '</pre>'
] |
Unix timestamp of change (timestamp) | '1741546084' |