haskell->Py->Ruby->

问题

突然抽风了——如何让一个程序打印出亲本身? - python-cnCPyUG华蟒用户组(中文Py用户组) | Google Groups

最NB!

third-order-quine-in-three-languages

  • p43129024-2

`这是一个 Haskell 程序,运行它会输出一个 Python 程序,再运行这个 Python 程序会输出一个 Ruby 程序,再运行这个 Ruby 程序会得到一个 Haskell 程序,对了!就和最开始那个 Haskell 程序一模一样的! `

$ runghc prself.hs
def q(a,b,c):print b+chr(10)+'q('+repr(b)+','+repr(c)+','+repr(a)+')'
q("def q(a,b,c):print
b+chr(10)+'q('+repr(b)+','+repr(c)+','+repr(a)+')'","def e(x) return
34.chr+x+34.chr end;def q(a,b,c) print b+10.chr+'main=q '+e(b)+' '+e(c)+'
'+e(a)+' '+10.chr end","q a b c=putStrLn $ b ++ [toEnum 10,'q','('] ++ show
b ++ [','] ++ show c ++ [','] ++ show a ++ [')']")

$ runghc prself.hs  | python
def e(x) return 34.chr+x+34.chr end;def q(a,b,c) print b+10.chr+'main=q
'+e(b)+' '+e(c)+' '+e(a)+' '+10.chr end
q("def e(x) return 34.chr+x+34.chr end;def q(a,b,c) print b+10.chr+'main=q
'+e(b)+' '+e(c)+' '+e(a)+' '+10.chr end","q a b c=putStrLn $ b ++ [toEnum
10,'q','('] ++ show b ++ [','] ++ show c ++ [','] ++ show a ++ [')']","def
q(a,b,c):print b+chr(10)+'q('+repr(b)+','+repr(c)+','+repr(a)+')'")

$ runghc prself.hs  | python | ruby
q a b c=putStrLn $ b ++ [toEnum 10,'q','('] ++ show b ++ [','] ++ show c ++
[','] ++ show a ++ [')']
main=q "q a b c=putStrLn $ b ++ [toEnum 10,'q','('] ++ show b ++ [','] ++
show c ++ [','] ++ show a ++ [')']" "def q(a,b,c):print
b+chr(10)+'q('+repr(b)+','+repr(c)+','+repr(a)+')'" "def e(x) return
34.chr+x+34.chr end;def q(a,b,c) print b+10.chr+'main=q '+e(b)+' '+e(c)+'
'+e(a)+' '+10.chr end" 


反馈

创建 by -- ZoomQuiet [2009-09-07 06:28:33]

Name Password4deL ;) :( X-( B-)

PageCommentData