CJam 0.6.6 dev / GolfScript,15 14 12字节
"0$p"0$~a:n;
感谢@ jimmy23013打高尔夫球2个字节!
休息要更新。
验证
由于提交涉及大量空白,因此最好比较十六进制转储。
$ xxd -g 1 mpquine
0000000: 22 60 30 24 7e 22 30 24 7e 4e 4d 3a 6e 3b "`0$~"0$~NM:n;
$
$ cjam mpquine | tee quine.gs | xxd -g 1
0000000: 22 60 30 24 7e 22 60 30 24 7e 0a "`0$~"`0$~.
$ golfscript quine.gs | xxd -g 1
0000000: 22 60 30 24 7e 22 60 30 24 7e 0a "`0$~"`0$~.
$ cjam quine.gs | xxd -g 1
0000000: 22 60 30 24 7e 22 60 30 24 7e "`0$~"`0$~
$
$ golfscript mpquine | tee quine.cjam | xxd -g 1
0000000: 22 60 30 24 7e 22 60 30 24 7e "`0$~"`0$~
$ cjam quine.cjam | xxd -g 1
0000000: 22 60 30 24 7e 22 60 30 24 7e "`0$~"`0$~
$ golfscript quine.cjam | xxd -g 1
0000000: 22 60 30 24 7e 22 60 30 24 7e 0a "`0$~"`0$~.
贾姆
CJam打印"`0$~"0$~
和尾随换行符。在线尝试!
生成的程序"`0$~"0$~
在GolfScript中使用尾随换行符打印(在线尝试!),而在CJam中不使用换行符打印(在线尝试!)。
间喹的工作原理
"`0$~" e# Push that string on the stack.
0$~ e# Push a copy and evaluate it:
e# ` Inspect the string, pushing "\"`0$~\"".
e# 0$ Push a copy.
e# ~ Evaluate, pushing "`0$~".
e# Both "\"`0$~\"" and "`0$~" are now on the stack.
NM e# Push "\n" and "".
:n; e# Map print over the elements of "" (none) and pop the result.
e# "\"`0$~\"", "`0$~", and "\n" are now on the stack, and the
e# characters they represent will be printed implicitly.
奎纳如何工作
"`0$~" # Push that string on the stack.
0$~ # As in CJam.
<LF> # Does nothing.
# "\"`0$~\"" and "`0$~" are now on the stack, and the characters
# they represent will be printed implicitly, plus a linefeed.
与GolfScript不同,CJam默认情况下不打印尾随换行符,因此这不是CJam中的奎因。
高尔夫脚本
GolfScript打印"`0$~"0$~
,没有尾随空白。在线尝试!
生成的程序打印时"`0$~"0$~
不会在CJam中尾随空格(尝试在线!),但是GolfScript追加了换行符(尝试在线!)。
间喹的工作原理
"`0$~"0$~ # As in CJam.
NM # Unrecognized token. Does nothing.
:n # Store the top of the stack – "`0$~" – in the variable n. n holds
# "\n" by default. When the program finishes, the interpreter
# prints n implicitly, usually resulting in a trailing linefeed.
# By redefining n, it will print "0$~" instead.
; # Pop the string from the stack so it won't be printed twice.
奎纳如何工作
"`0$~"0$~ e# Works as in GolfScript.
与CJam不同,GolfScript会将换行符附加到堆栈的内容中,因此,这在GolfScript中不是一个问题。