Essays/Self
< Essays
Jump to navigation
Jump to search
"Write a program that prints its own source code".
See the catalog at Puzzles/Quine
In J that would be "write an expression that results in a string composed of the same characters in the same sequence as the original expression".
Another way to say it is to define a string s such that (-: ".)s
It can be debated whether the empty string counts as a J expression and therefore is an allowable entry, so to reduce trivial discussion let's assume non-empty s.
Here is a solution:
(,~,{:,{:)'(,~,{:,{:)'''
And another one:
(,{:)^:2,~'(,{:)^:2,~'''
And this one has the same length (24 characters) now but may be reduced to 22 in (future) J6
(,2:#{:),~'(,2:#{:),~'''
Can there be shorter expressions with this property?
Is it possible to construct expression with this property that has odd number of characters?