woensdag 19 maart 2014

A quine in Elm

Quines are self-reproducing programs, programs whose output is itself. Quines can get very complex, but some languages are apperently more suited to create quines. Yesterday I made a quine in Elm:

main = (\x -> plainText x `beside` plainText (show x))"main = (\\x -> plainText x `beside` plainText (show x))"

The program consists of two parts: displaying the quine and the program source itself within a string. I used show to deal with the string quoting and escaping of the backslash.

Check it out: http://share-elm.com/sprout/532b19d4e4b0f7cc0dd4ed99