我觉得> <>可能不是最好的语言,但是我走得太远了,不能放弃并且不发布它。第*
4行结尾处的假定为空格。您不喜欢这段代码看起来多么怪异吗?在线尝试。
<v?(0:i
v>~" ## "}}l:::
>"#"o1-:?!v02.>~a"#"oo
"-2ooa"#"~<.31v!?:-1o"
7v?=3loroo"#"a<.4
.>";^"e3pa2p093
这是一个除了方向转换器之外没有其他任何版本的版本,它可以使您了解指针如何移动(请注意,我省略了“ teleport”语句,即.
)。
方向流:
<v
v>
> v >
< v
v <
>
说明
我对堆栈的可视化将基于输入 input
。> <>是一种二维语言,因此在执行其下面的代码时(在此代码中),请注意指针在行之间移动的位置<>v^
中主要用于更改方向)。我将从指针开始的地方开始我的解释。注意,随着指针在第五行之后向后移动,将重复两行。
我总是对> <>感到很酷的地方是它能够修改自己的源代码,并且我在此程序中使用了它。第3行和第4行可重复使用,以通过修改每个字符来打印最后两行。
第1行:输入回路
<v?(0:i
< change direction to left
(0:i checks if input is less than 0 (no input defaults to -1)
v? change direction to down if so
堆: [-1,t,u,p,n,i]
第2行:生成第三行输出
v>~" ## "}}l:::
>~" ## "}} remove -1 (default input value) from stack and pads with # and spaces
l::: push 4 lengths of padded input
堆: [9,9,9,9,#, ,t,u,p,n,i, ,#]
第3行:打印输出的第一行
>"#"o1-:?!v02.>~a"#"oo
>"#"o print "#"
1- subtract 1 from length (it's at the top of the stack)
:?!v move down if top of stack is 0
堆: [0,9,9,9,#, ,t,u,p,n,i, ,#]
输出:
#########
第4行:打印输出的第二行
"-2ooa"#"~<.31v!?:-1o"*
-2ooa"#"~< pops 0, prints newline, "#", then decrements length by 2
" o"* prints space (* is supposed to be space char)
-1 decrements top of stack
.31v!?: changes direction to down if top of stack is 0, else jumps back to "
堆: [0,9,9,#, ,t,u,p,n,i, ,#]
输出(*
代表空格):
#########
#*******
第5行:打印输出的第三行
7v?=3loroo"#"a<.4
oo"#"a< prints "#",newline
r reverses stack
7v?=3lo .4 outputs until stack has 3 values, then changes direction to down
堆: [9,9,0]
输出:
#########
# #
# input #
第6行:设置为输出第四行和第五行
.>";^"e3pa2p093
>";^" push ";",then "^"
e3p place "^" as the fifteenth character on line 4
a2p place ";" as the eleventh character on line 3
0 push a value (value doesn't matter -- it will be deleted)
. 93 jump to the tenth character on line 4
堆: [0,9,9,0]
第4行:打印输出的第四行
"-2ooa"#"~<.31^!?:-1o"*
ooa"#"~< delete 0 (unnecessary value pushed), then print newline,"#"
-2 subtract two from value on top of stack (length)
" .31^!?:-1o"* print space until top of stack is 0, then change direction to up
堆: [0,9,0]
输出(*
代表空格):
#########
# #
# input #
#*******
第三行:打印输出的最后一行
"#"o1-:?!;02.>~a"#"oo
>~a"#"oo pop top of stack, print "#", newline
"#"o1-:?!;02. print "#" until top of stack is 0, then terminate
堆: [0,0]
输出:
#########
# #
# input #
# #
#########