Eigen Class
Posts: 358
Nickname: eigenclass
Registered: Oct, 2005
|
Eigenclass is a hardcore Ruby blog.
|
|
|
|
More self-references: Ruby speaking languages in ASCII demos
|
Posted: Jan 3, 2006 5:57 AM
|
|
I decided to imitate chris2's
xmas
animations
and posted a rather large one
to ruby-talk (to be fair, I actually used some filler to display the whole AA). If you run it, you'll notice it's also quine-like... The code looks like this:
which stands for "happy new year" in Japanese.
For the sake of symmetry, I also made the following
The carrier, with base64-encoded text arranged to form some ASCII art,
is based on Christian's original one, with a twist to:
- remove all the prefix code
- feed the encoded ehhmm code (i.e. the sources as found in the message, minus the trailing decoder) to the lambda resulting from evaluating that code
It basically works like
"LENGTH base 64 text
here, whose spaces will be removed before unpacking;
Essentially, something like:
lambda do |myself|
... do something with my own sources ...
end".
instance_eval do |x|
y = x.gsub(/ \\n/, "")
eval(y[5,y[0,5].to_i].unpack("m*")[0]).call(x)
end
Few people ever use that, but instance_eval passes self to the block; it is
thanks to this that I can move all the code to the bottom, leaving a mere
quotation mark as the prefix, so it barely disturbs the ASCII art.
Read more...
Read: More self-references: Ruby speaking languages in ASCII demos
|
|