Execute SNUSP/Haskell: Difference between revisions

Extension: 3rd dimension
m (Redo hGetChar stdin --> getChar (forgot to refresh edit page))
(Extension: 3rd dimension)
Line 174:
[s] <- getArgs
runFile s
</pre>
 
== Extension ==
 
To demonstrate the easy of introducing even more dimensions, let's implement commands ( and ) to move the data pointer along the z-axis, and a command ^ to rotate the IP direction around the (1,1,1) axis (i.e., left becomes up, up becomes "further" on the z-axis, "further" becomes left, etc.).
 
<pre>
exec '(' d t = moveMp d t [0,0,-1]
exec ')' d t = moveMp d t [0,0, 1]
exec '^' d t = return [t {dir=(d3:d1:d2:ds)}] where d1:d2:d3:ds = dir t <+> [0,0,0]
</pre>
Anonymous user