112 captures
16 Feb 2009 - 01 Jan 2026
Apr MAY Jun
24
2012 2013 2014
success
fail

About this capture

COLLECTED BY

Organization: Alexa Crawls

Starting in 1996, Alexa Internet has been donating their crawl data to the Internet Archive. Flowing in every day, these data are added to the Wayback Machine after an embargo period.

Collection: Alexa Crawls

Starting in 1996, Alexa Internet has been donating their crawl data to the Internet Archive. Flowing in every day, these data are added to the Wayback Machine after an embargo period.
TIMESTAMPS

The Wayback Machine - http://web.archive.org/web/20130524011843/http://blog.sigfpe.com:80/2008/02/third-order-quine-in-three-languages.html
 






A Neighborhood of Infinity








 

Tuesday, February 05, 2008




A Third Order Quine in Three Languages



Suppose Fnxy is a program, written in language x, that takes as input n string arguments as input, G1,...,Gn and outputs a program in language y that is the application of the function whose source code is G2 to the strings G2,G3,...,Gn,G1. Then F3xy(F3xy,F3yz,F3zx) will be a program in language x that that outputs a program in y that computes F3yz(F3yz,F3zx,F3xy).

We can put this into practice:


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"


This is a Haskell program that outputs a Python program that outputs a Ruby program that outputs the original Haskell program. 

Apologies for the lack of line breaks. If it's not readable, it should be possible to copy and paste that source. Also, you may need to tweak it if your OS doesn't treat character 10 as a new line.



Posted by Dan Piponi atTuesday, February 05, 2008
Labels: , ,




15 comments:





cypher said...


That is awesome.


Wednesday, 06 February, 2008

Nikolay said...


[15:27 /]$ ghci
 ___ ___ _
 / _ \ /\ /\/ __(_)
 / /_\// /_/ / / | | GHC Interactive, version 6.6.1, for Haskell 98.
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
\____/\/ /_/\____/|_| Type :? for help.

Prelude> q a b c=putStrLn $ b ++ [toEnum 10,'q','('] ++ show b ++ [','] ++ show c ++ [','] ++ show a ++ [')']
< interactive >:1:7: parse error on input `='


Wednesday, 06 February, 2008

Anonymous said...


Impressive O_O


Wednesday, 06 February, 2008

Brent said...


nice!

Nikolay: you won't be able to just paste it into ghci like that, you'll have to put it in a file and then load the file into ghci.


Wednesday, 06 February, 2008

mzz said...


nikolay:
Write it into .hs file and use runhaskell to execute it.
ghci expects let before name bindings to distinguish them from expressions.


Wednesday, 06 February, 2008

Nikolay said...


Ooh, I see. Thanks! It is really awesome!


Wednesday, 06 February, 2008

jk said...


Wow! That is really awesome.


Friday, 08 February, 2008

Anonymous said...


Wow! You're all dorks


Wednesday, 13 February, 2008

Anonymous said...


Amazing :)


Wednesday, 19 March, 2008

Anonymous said...


...please where can I buy a unicorn?


Wednesday, 16 December, 2009

paurullan said...


Gorgeous!


Wednesday, 31 March, 2010

Paul Hobbs said...


This is so fascinating! You are awesome =]


Monday, 20 September, 2010

SteelToad said...


What this really needs is a recursive function


Tuesday, 25 January, 2011

Anonymous said...


it formatted my pr0n.


Tuesday, 25 January, 2011

Anonymous said...


runhaskell 3quine |python|ruby|diff 3quine -


*blinks*
*awe*


Wednesday, 26 January, 2011


Post a Comment







 

Newer Post Older Post Home



Subscribe to: Post Comments (Atom)


Blog Archive






     2013 (2)

     April (1)



     January (1)





     2012 (8)

     December (1)



     November (1)



     April (1)



     March (1)



     February (2)



     January (2)





     2011 (13)

     October (1)



     August (1)



     July (2)



     June (2)



     May (1)



     April (3)



     February (2)



     January (1)





     2010 (20)

     December (2)



     November (2)



     September (2)



     August (2)



     July (2)



     May (2)



     April (1)



     March (2)



     February (2)



     January (3)





     2009 (21)

     December (1)



     November (2)



     October (3)



     September (3)



     July (1)



     June (2)



     May (2)



     April (1)



     March (1)



     February (1)



     January (4)





  2008 (35)

     December (1)



     November (3)



     October (3)



     September (3)



     August (5)



     July (2)



     June (3)



     May (4)



     April (2)



     March (3)



  February (4)

What is Topology?

How many functions are there from () to ()? (Updat...

A Third Order Quine in Three Languages

Purely functional recursive types in Haskell and P...





     January (2)





     2007 (37)

     December (1)



     November (5)



     October (2)



     September (3)



     July (3)



     June (2)



     May (1)



     April (3)



     March (7)



     February (6)



     January (4)





     2006 (92)

     December (4)



     November (6)



     October (3)



     September (6)



     August (6)



     July (6)



     June (8)



     May (8)



     April (8)



     March (20)



     February (9)



     January (8)





     2005 (53)

     December (3)



     November (3)



     October (4)



     September (7)



     August (11)



     July (15)



     June (4)



     May (6)









Some Links




The Comonad.Reader

Rubrication

Richard Borcherds: Mathematics and physics

The n-Category Cafe

Ars Mathematica





About Me


My Photo



Blog: A Neighborhood of Infinity
Code: Github
Twitter: sigfpe
Home page: www.sigfpe.com