996
|
1 2L is a deceptively confusing but non-complex language. Like PATH and Befunge, it's
|
|
2 two-dimensional. Like BrainFuck, it operates on a tape. However, it only has two symbols. It
|
|
3 manages this by overloading the * symbol by direction. Your data pointer starts at location 2,
|
|
4 not 0 as in BrainFuck, because 0 and 1 are significant. The tape is filled with 0s, as in BF.
|
|
5 Your program pointer starts at 0,0 moving down, and ends when the program pointer goes below 0
|
|
6 left or up. Here are the symbols:
|
|
7
|
|
8 SYMBOL | FUNCTION
|
|
9 ----------+----------
|
|
10 * | All IO and tape operations. This operation has a different function for all four
|
|
11 | cardinal directions:
|
|
12 | Up: Move the data pointer to the right (> in BF)
|
|
13 | Down: Move the data pointer to the left (< in BF)
|
|
14 | Left: Decrement the value at the data pointer (- in BF)
|
|
15 | Right: Increment the value at the data pointer (+ in BF)
|
|
16 |
|
|
17 + | if the value the data pointer points to is nonzero, turn right
|
|
18 | otherwise turn left
|
|
19
|
|
20 Tape locations 0 and 1 are significant. 1 doesn't actually hold a value, it mearly causes an IO
|
|
21 operation if you attempt to increment or decrement it. (I will from here on shorten "Tape
|
|
22 location" to "TL")
|
|
23 If the value at TL0 is 0, and you attempt to change the value of TL1, a character will be read from
|
|
24 input into TL0. If TL0 is not 0, and you attempt to change the value of TL1, a character will be
|
|
25 outputted from the value of TL0.
|
|
26
|
|
27 The + turn is not a simple turn. Imagine the lines are your path:
|
|
28 |
|
|
29 |
|
|
30 -----------/+
|
|
31
|
|
32 Is the direction of your program pointer, rather than
|
|
33 |
|
|
34 |
|
|
35 -----------+
|
|
36
|
|
37 This is because the second method would make many types of loop impossible. Trust me .... I spent
|
|
38 way to long figuring that out.
|
|
39
|
|
40 Here's a simple loop, that produces the value 9 by multiplying 5 by two then subtracting 1:
|
|
41
|
|
42 ** +
|
|
43 +
|
|
44 * *****+
|
|
45 +
|
|
46 + *
|
|
47 + *
|
|
48 +
|
|
49 <* +
|
|
50 +
|
|
51
|
|
52 The < is the direction that your program pointer will be going in when you're done producing the
|
|
53 value. Here's how it works:
|
|
54
|
|
55 --**-\+
|
|
56 +|
|
|
57 * *****+
|
|
58 +|/ |
|
|
59 |+ *
|
|
60 + ----*/
|
|
61 + +
|
|
62 <* +
|
|
63 +
|
|
64
|
|
65 That's more helpful, right? No? OK, lesse...
|
|
66 The first two * you hit increases your value to 2
|
|
67 You then turn right, go down, turn left then up...
|
|
68
|
|
69 Now you're here:
|
|
70 /----\
|
|
71 | + |
|
|
72 | * *|
|
|
73 |+^ |
|
|
74 | + |
|
|
75 \----/
|
|
76
|
|
77 You'll hit that * going up, and hence shift your data pointer's location.
|
|
78 Now you'll hit that series of five *s, which will increase your value by 5.
|
|
79 Then you turn down, and hit that next * below there. That makes you go back down to the cell with
|
|
80 the value 2. Then you turn right, and are going left. You hit that *, and decrement.
|
|
81 Still with me? No? Good.
|
|
82
|
|
83 Now you're here:
|
|
84 /----\
|
|
85 | +|
|
|
86 | + <|
|
|
87 | +|
|
|
88 | * |
|
|
89 \----/
|
|
90
|
|
91 You'll hit that +. The first time, you'll still have a value of 1, so you'll turn right and go
|
|
92 into the loop again. The second time, you'll have a value of 0, and will hence turn left.
|
|
93 Then you'll go all the way to the right, and the two +s there will turn you around. You hit that
|
|
94 final * (next to the output <), and then your 10 (remember, you added 5 twice) is now 9!
|
|
95
|
|
96 WOW! That was simple!
|
|
97
|
|
98 That's it! That's the whole language! Isn't that simple ... but not!
|