Dear Ruby fans,
A common Lisp exercise is to write a Lisp program that writes its own
source code to standard output. Reading from a source file is not
permitted.
This leads one to wonder: what is the smallest and / or most elegant
Ruby program that writes its own source code to standard output? As
with Lisp, reading from a file is not permitted. Given the nature of
the language, this problem should should have a lot of interesting
solutions.
This is called a Quine, right? I can't beat Ryan Davis', so I'll just
link to it. 
http://blog.zenspider.com/archives/2006/09/ruby_quine__sli.html
···
On Mon, Oct 22, 2007 at 11:25:02AM +0900, Frank J. Lhota wrote:
Dear Ruby fans,
A common Lisp exercise is to write a Lisp program that writes its own
source code to standard output. Reading from a source file is not
permitted.
This leads one to wonder: what is the smallest and / or most elegant
Ruby program that writes its own source code to standard output? As
with Lisp, reading from a file is not permitted. Given the nature of
the language, this problem should should have a lot of interesting
solutions.
--
Aaron Patterson
http://tenderlovemaking.com/
My favorite Ruby quine is
<code>
DATA.rewind
STDOUT.write(DATA.read)
__END__
</code>
Regards, Morton
···
On Oct 21, 2007, at 10:25 PM, Frank J. Lhota wrote:
Dear Ruby fans,
A common Lisp exercise is to write a Lisp program that writes its own
source code to standard output. Reading from a source file is not
permitted.
This leads one to wonder: what is the smallest and / or most elegant
Ruby program that writes its own source code to standard output? As
with Lisp, reading from a file is not permitted. Given the nature of
the language, this problem should should have a lot of interesting
solutions.
There's a whole page of Ruby quines (including 2 of my own) in the
rubygarden wiki: http://rubygarden.org/Ruby/page/show/RubyQuines
···
On Oct 21, 10:21 pm, "Frank J. Lhota" <Frank_J_Lh...@Raytheon.com> wrote:
This leads one to wonder: what is the smallest and / or most elegant
Ruby program that writes its own source code to standard output? As
with Lisp, reading from a file is not permitted. Given the nature of
the language, this problem should should have a lot of interesting
solutions.
Very nice. I looked up "DATA" in the pickaxe and found that I had
previously highlighted it - must've been a long time ago. Here's a
rewindless version 
puts DATA.read * 2
__END__
puts DATA.read * 2
__END__
···
On Oct 22, 1:35 pm, Morton Goldberg <m_goldb...@ameritech.net> wrote:
On Oct 21, 2007, at 10:25 PM, Frank J. Lhota wrote:
> Dear Ruby fans,
> A common Lisp exercise is to write a Lisp program that writes its own
> source code to standard output. Reading from a source file is not
> permitted.
> This leads one to wonder: what is the smallest and / or most elegant
> Ruby program that writes its own source code to standard output? As
> with Lisp, reading from a file is not permitted. Given the nature of
> the language, this problem should should have a lot of interesting
> solutions.
My favorite Ruby quine is
<code>
DATA.rewind
STDOUT.write(DATA.read)
__END__
</code>