StackX

From Esolang
Jump to navigation Jump to search

StackX is a stack-based golfing programming language influenced by Getchl, Befunge, ><> and 05AB1E.

Command List

Charcode Unicode Instruction Meaning
32 Space Nothing NOP
33 ! Not 0 and NaN become 1, everything else becomes 0
34 " String Push Unicode of all characters up to the next "
35 # Print Pop x, print x
36 $ Drop Pop x and discard
37 % Remainder Pop x and y, push y%x
38 & Input Get a single numeric value from input (NaN on EOF)
39 ' Char Pushes charcode of next character
40 ( Block Starts a code block
41 ) Block End Ends a code block
42 * Multiply Pop x and y, push y*x
43 + Add Pop x and y, push y+x
44 , Print Character Pop x, print Unicode character whose value is x (rounded down). Error if negative, infinite or NaN.
45 - Subtract Pop x and y, push y-x
46 . Decimal Point Denotes decimal point in number literals
47 / Divide Pop x and y, push y/x
48-57 0-9 Digits Used in number literals
58 : Duplicate Pop x, push x and x
59 ; Shift Enter shift mode for the next character
60 < Back Pop x, go back on the tape by x
61 = Execute Pop 0gnirts, execute as system command (no equal command because of subtraction)
62 > Forward Pop x, go forward on the tape by x
63 ? If Do last command/codeblock unless top of stack is 0 or NaN
64 @ While Do last command/codeblock until top of stack is 0 or NaN
65 A A Pop x, set register A to x
66 B B Pop x, set register B to x
67 C C Pop x, set register C to x
68 D D Pop x, set register D to x
69 E E Push 2.71828...
70 F Fizzbuzz Pop x, print fizzbuzz until x
71 G Get Pop x, push charcode of xth character in code (newlines ignored, space pushes 0, overflow pushes NaN)
72 H Hello World Print "Hello World"
73 I Infinity Push positive infinity
74 J Loop Counter Push loop counter, NaN if outside for loop
75 K
76 L Length Push the number of values on the stack
77 M Memory Pop x, set accumulator to x
78 N Ninety Nine Bottes Print 99 bottles of beer lyrics
79 O Over Pop n, duplicate the nth stack item
80 P Put Pop x, n, set the nth command to Unicode character x
81 Q Quine Push 81 (I'm sorry)
82 R Run Pop 0gnirts, run it as StackX code
83 S
84 T Truth Machine Pop x, print 0 if x is 0, print 1 forever if x is 1
85 U
86 V
87 W
88 X X Pop x, set register X to x
89 Y Y Pop x, set register Y to x
90 Z Sleep Pop x, sleep of x milliseconds
91 [ Rotate Pop a, b, c, push a, c, b
92 \ Swap Pop a, b, push a, b
93 ] Rotatecc Pop a, b, c, push b, a, c
94 ^ Power Pop a, b, push b**a
95 _ Negate Pop x, push -x
96 ` Eval Pop 0ginrts, run it through JS eval(), then push the stringified result.
97 a a Push register A value
98 b b Push register B value
99 c c Push register C value
100 d d Push register D value
101 e equals Pop x, y, if x==y and neither is NaN, push 1, else push 0
102 f find Pop x, pop y repeatedly until y=x
103 g goto Pop x, jump to label x
104 h hundred Push 100
105 i increment Pop x, push x+1
106 j decrement Pop x, push x-1
107 k
108 l label Pop x, label as goto location
109 m memory Push accumulator value
110 n nan Push NaN
111 o
112 p pi Push 3.14159...
113 q queue Turn stack into queue (another q turns it back into a stack)
114 r reverse Reverse the stack
115 s sign Pop x, push sign of x (NaN if x is NaN)
116 t ten Push 10
117 u up Move bottom value up (roll operation in queue mode)
118 v down Move top value down
119 w Example Example
120 x x Push register X value
121 y y Push register Y value
122 z done End program without implicit output or break out of loop
123 { To String Pop x, convert it into 0gnirts and push
124 | Define Pop x, define corresponding function as previous command or block
125 } To Number Pop 0gnirts, convert it into number using Javascript Number()
126 ~ Input Character get a single charcode from input (-1 on EOF)
161 ¡ 00 Open Pop 0gnirts, open the corresponding file
162 ¢ 01 Read Pop 0gnirts, read the content and push
163 £ 02 Write Pop 0gnirts s and t, write t to file s
164 ¤ 03 Replace Pop strings s, t and u, then replace s with t in u, push u
165 ¥ 04 Concatenate Pop string s and t, concatenate and push the result
166 ¦ 05 Function Pop x, run function x
167 § 06 Sequence Product Pop 0gnirts, a, concatenate 0gnirts a (rounded down) times, then push it back
168 ¨ 07 Infinite Loop Repeat the last command/codeblock infinitely
169 © 08 32 More Pop x, push x+32
170 ª 09 32 Less Pop x, push x-32
171 « 10 Left Shift Pop x, push 2x
172 ¬ 11 64 More Pop x, push x+64
174 ® 12 64 Less Pop x, push x-64
175 ¯ 13 Numbered Shift Pop x, toggle n-tuple shift mode for next command
176 ° 14 Power Of Ten Pop x, push 10**x
177 ± 15 Sign Pop x, push sign of x (NaN if x is NaN)
178 ² 16 Square Pop x, push x**2
179 ³ 17 Cube Pop x, push x**3
180 ´ 18 Greater Than Pop x, y, push 1 if y>x, else push 0
181 µ 19 Split Pop strings s and t, split t by s, then push every item.
182 ¶ 20 Carriage Return Push 13
183 · 21
184 ¸ 22
185 ¹ 23 Reverse Pop string s, push its reverse
186 º 24 Mirror Machine Execute a mirror machine
187 » 25 Right Shift Pop x, push x/2
188 ¼ 26 For Loop From One Pop x, do last command/block for (J=1; J<=x; J++)
189 ½ 27 For Loop From Zero Pop x, do last command/block for (J=0; J<=x; J++)
190 ¾ 28 For Loop With Range Pop x, y, do last command/block for (J=y; J<=x; J++)
191 ¿ 29 Factorial Pop x, push x!
192 À 30 Is Even Pop x, push 1 if a % 2 == 0 else 0
193 Á 31 Is Odd Pop x, push 1 if a % 2 == 1 else 0
194 Â 32 Is Prime Pop x, if x is prime, push 1, else push 0
195 Ã 33 Is Integer Pop x, push 1 if x % 1 == 0, else push 0
196 Ä 34 Regex Match Pop regex r, string s, push all matches of r in s
197 Å 35 Å Push 197 (I'm sorry again)
198 Æ 36 All The Same Push 1 if no duplicates in stack (NaN == NaN here), else 0
199 Ç 37 Clear All Registers A = B = C = D = M = X = Y = NaN
200 È 38 Exponential Pop x, push e**x
Charcode Unicode Instruction Meaning
201 É 39 Natural Logarithm Pop x, push ln(x)
202 Ê 40 Is Not Numeric Pop string s, push 1 if isNaN(s), else 0
203 Ë 41 Fraction Pop x, push x as a fraction (0gnirts) Infinity = '1/0', NaN = '0/0'.
204 Ì 42 Ten More Pop x, push x+10
205 Í 43 Ten Less Pop x, push x-10
206 Î 44 Absolute Value Pop x, push abs(x)
207 Ï 45 Random Number Push random integer from 1 to Number.MAX_SAFE_INTEGER
208 Ð 46 Copy Pop x, y, push y x times
209 Ñ 47 Ñ Push 209 (I'm sorry again)
210 Ò 48 Times 10 Pop x, push 10x
211 Ó 49 Divide By 10 Pop x, push x/10
212 Ô 50 Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example
Example Example Example Example

Implicit output: If nothing is printed after termination, print the stack until the next null terminator (or the whole stack if no null terminator) as a string.