⇤ ← Revision 1 as of 2009-09-07 06:28:33
Size: 2348
Comment:
|
Size: 2348
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 17: | Line 17: |
[third-order-quine-in-three-languages http://blog.sigfpe.com/2008/02/third-order-quine-in-three-languages.html] | [http://blog.sigfpe.com/2008/02/third-order-quine-in-three-languages.html third-order-quine-in-three-languages] |
haskell->Py->Ruby->
问题
[http://groups.google.com/group/python-cn/browse_thread/thread/6d100ad6ef9feecf 突然抽风了——如何让一个程序打印出亲本身?] - python-cnCPyUG华蟒用户组(中文Py用户组) | Google Groups
最NB!
[http://blog.sigfpe.com/2008/02/third-order-quine-in-three-languages.html third-order-quine-in-three-languages]
`这是一个 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 [DateTime(2009-09-07T06:28:33Z)]