Page namespace (page_namespace) | 0 |
Page title (without namespace) (page_title) | 'ABC' |
Full page title (page_prefixedtitle) | 'ABC' |
Old content model (old_content_model) | 'wikitext' |
New content model (new_content_model) | 'wikitext' |
Old page wikitext, before the edit (old_wikitext) | ':''Not to be confused with tom7's [[ABC (compiler)]], [[AlPhAbEt]], nor [[Abc]].''
ABC is an esoteric programming language created by [[User:Orange]]. The language is very simple and easy to implement. This language has nothing to do with the real programming language [https://en.wikipedia.org/wiki/ABC_(programming_language) ABC].
==Instructions==
a - Increment the accumulator
b - Decrement the accumulator
c - Output the accumulator
d - Invert accumulator
r - Set accumulator to a random number between 0 and accumulator
n - Set accumulator to 0
$ - Toggle ASCII output mode. When on, the c instruction prints the accumulator as an ASCII character.
l - Loop back to the beginning of the program. Accumulator and ASCII mode does not reset.
; - Debug. Prints out accumulator as a number and ascii character.
Unknown instructions are treated as NOPs.
==Examples==
===Print out 1337===
acaaccaaaac
===Simulate a dice throw===
aaaaarac
===Random phone number generator===
ac
naaaaaaaaradc
naaaaaaaaarc
naaaaaaaaarc
naaaaaaaaradc
naaaaaaaaarc
naaaaaaaaarc
naaaaaaaaradc
naaaaaaaaarc
naaaaaaaaarc
naaaaaaaaarc
===[[Hello World]]===
$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacaaaaaa
aaaaaaaaaaaaaaaaaaaaaaacaaaaaaaccaaacnaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aacbbbbbbbbbbbbcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacaaaaaaaa
aaaaaaaaaaaaaaaacaaacbbbbbbcbbbbbbbbcnaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac
===Count infinitely===
acl
===Beep infinitely using ASCII code 7 (bell)===
aaaaaaa$cn$l
==Resources==
===Interpreters===
====Java====
public class ABC{
public static void interpreter(String code){
int acc=0;
boolean stringMode=false;
for(int i=0;i<code.length();i++){
switch(code.charAt(i)){
case'a':++acc;break;
case'b':--acc;break;
case'c':if(stringMode)System.out.print((char)acc);
else System.out.print(acc);
break;
case'd':acc*=-1;break;
case'r':acc=(int)Math.floor(Math.random()*(acc+1));break;
case'n':acc=0;break;
case'$':stringMode=(stringMode==false)?true:false;break;
case'l':i=-1;break;
case';':System.out.print(acc+" "+(char)acc);
}
}
}
}
====External Interpreters====
* [http://zzo38computer.org/esoteric/ABC/ABC.php ABC in PHP] {{deadlink}}
* [http://www.shorttext.com/li35q5 ABC in Python] {{deadlink}}
* [http://www.shorttext.com/9hqeqg ABC in Java] {{deadlink}}
* [http://www.shorttext.com/85ozcq ABC in scheme] {{deadlink}}
===Discussions===
* [[Talk:ABC|Talk for ABC]]
* [http://dis.4chan.org/read/prog/1217371234 Thread about ABC on 4chans /prog/ text board. Contains many implementations, including the above Algorithmic Language implementation.] {{deadlink}}
[[Category:Languages]]
[[Category:2008]]
[[Category:Implemented]]
[[Category:Unusable for programming]]' |
New page wikitext, after the edit (new_wikitext) | ':''Not to be confused with tom7's [[ABC (compiler)]], [[AlPhAbEt]], nor [[Abc]].''
ABC is an esoteric programming language created by [[User:Orange]]. The language is very simple and easy to implement. This language has nothing to do with the real programming language [https://en.wikipedia.org/wiki/ABC_(programming_language) ABC].
==Instructions==
a - Increment the accumulator
b - Decrement the accumulator
c - Output the accumulator
d - Invert accumulator
r - Set accumulator to a random number between 0 and accumulator
n - Set accumulator to 0
$ - Toggle ASCII output mode. When on, the c instruction prints the accumulator as an ASCII character.
l - Loop back to the beginning of the program. Accumulator and ASCII mode does not reset.
; - Debug. Prints out accumulator as a number and ascii character.
Unknown instructions are treated as NOPs.
==Examples==
===Print out 1337===
acaaccaaaac
===Simulate a dice throw===
aaaaarac
===Random phone number generator===
ac
naaaaaaaaradc
naaaaaaaaarc
naaaaaaaaarc
naaaaaaaaradc
naaaaaaaaarc
naaaaaaaaarc
naaaaaaaaradc
naaaaaaaaarc
naaaaaaaaarc
naaaaaaaaarc
===[[Hello World]]===
$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacaaaaaa
aaaaaaaaaaaaaaaaaaaaaaacaaaaaaaccaaacnaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aacbbbbbbbbbbbbcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacaaaaaaaa
aaaaaaaaaaaaaaaacaaacbbbbbbcbbbbbbbbcnaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac
===Count infinitely===
acl
===Beep infinitely using ASCII code 7 (bell)===
aaaaaaa$cn$l
==Resources==
===Interpreters===
====Java====
public class ABC{
public static void interpreter(String code){
int acc=0;
boolean stringMode=false;
for(int i=0;i<code.length();i++){
switch(code.charAt(i)){
case'a':++acc;break;
case'b':--acc;break;
case'c':if(stringMode)System.out.print((char)acc);
else System.out.print(acc);
break;
case'd':acc*=-1;break;
case'r':acc=(int)Math.floor(Math.random()*(acc+1));break;
case'n':acc=0;break;
case'$':stringMode=(stringMode==false)?true:false;break;
case'l':i=-1;break;
case';':System.out.print(acc+" "+(char)acc);
}
}
}
}
==== Python ====
import sys
import random
prog = """
aaaaarac
"""
acc = 0
pc = 0
ascii_mode = False
while True:
if prog[pc] == 'a':
acc += 1
elif prog[pc] == 'b':
acc -= 1
elif prog[pc] == 'c':
if ascii_mode:
sys.stdout.write(chr(acc))
else:
sys.stdout.write(str(acc) + ' ')
elif prog[pc] == 'd':
acc *= -1
elif prog[pc] == 'r':
acc = random.randrange(0, acc)
elif prog[pc] == 'n':
acc = 0
elif prog[pc] == '$':
ascii_mode = not ascii_mode
elif prog[pc] == 'l':
pc = 0
elif prog[pc] == ';':
print(acc, chr(acc))
pc += 1
if pc == len(prog):
sys.stdout.write('\n')
break
====External Interpreters====
* [http://zzo38computer.org/esoteric/ABC/ABC.php ABC in PHP] {{deadlink}}
* [http://www.shorttext.com/li35q5 ABC in Python] {{deadlink}}
* [http://www.shorttext.com/9hqeqg ABC in Java] {{deadlink}}
* [http://www.shorttext.com/85ozcq ABC in scheme] {{deadlink}}
===Discussions===
* [[Talk:ABC|Talk for ABC]]
* [http://dis.4chan.org/read/prog/1217371234 Thread about ABC on 4chans /prog/ text board. Contains many implementations, including the above Algorithmic Language implementation.] {{deadlink}}
[[Category:Languages]]
[[Category:2008]]
[[Category:Implemented]]
[[Category:Unusable for programming]]' |
Unified diff of changes made by edit (edit_diff) | '@@ -79,4 +79,43 @@
}
}
+
+==== Python ====
+
+ import sys
+ import random
+
+ prog = """
+ aaaaarac
+ """
+
+ acc = 0
+ pc = 0
+ ascii_mode = False
+ while True:
+ if prog[pc] == 'a':
+ acc += 1
+ elif prog[pc] == 'b':
+ acc -= 1
+ elif prog[pc] == 'c':
+ if ascii_mode:
+ sys.stdout.write(chr(acc))
+ else:
+ sys.stdout.write(str(acc) + ' ')
+ elif prog[pc] == 'd':
+ acc *= -1
+ elif prog[pc] == 'r':
+ acc = random.randrange(0, acc)
+ elif prog[pc] == 'n':
+ acc = 0
+ elif prog[pc] == '$':
+ ascii_mode = not ascii_mode
+ elif prog[pc] == 'l':
+ pc = 0
+ elif prog[pc] == ';':
+ print(acc, chr(acc))
+ pc += 1
+ if pc == len(prog):
+ sys.stdout.write('\n')
+ break
====External Interpreters====
' |
Lines added in edit (added_lines) | [
0 => '',
1 => '==== Python ====',
2 => '',
3 => ' import sys',
4 => ' import random',
5 => ' ',
6 => ' prog = """',
7 => ' aaaaarac',
8 => ' """',
9 => ' ',
10 => ' acc = 0',
11 => ' pc = 0',
12 => ' ascii_mode = False',
13 => ' while True:',
14 => ' if prog[pc] == 'a':',
15 => ' acc += 1',
16 => ' elif prog[pc] == 'b':',
17 => ' acc -= 1',
18 => ' elif prog[pc] == 'c':',
19 => ' if ascii_mode:',
20 => ' sys.stdout.write(chr(acc))',
21 => ' else:',
22 => ' sys.stdout.write(str(acc) + ' ')',
23 => ' elif prog[pc] == 'd':',
24 => ' acc *= -1',
25 => ' elif prog[pc] == 'r':',
26 => ' acc = random.randrange(0, acc)',
27 => ' elif prog[pc] == 'n':',
28 => ' acc = 0',
29 => ' elif prog[pc] == '$':',
30 => ' ascii_mode = not ascii_mode',
31 => ' elif prog[pc] == 'l':',
32 => ' pc = 0',
33 => ' elif prog[pc] == ';':',
34 => ' print(acc, chr(acc))',
35 => ' pc += 1',
36 => ' if pc == len(prog):',
37 => ' sys.stdout.write('\n')',
38 => ' break'
] |