Following my entry to the Obfuscated Hello World I thought it might be fun to share the underlying code. But why just show the code, lets make it a golf too!
Challenge
Write a script that scrolls a string across the terminal, from right to left, settling on the left side.
Input
Takes a string as an argument.
Result
Prints the scrolling marquee to STDOUT. Max width of ~50 chars. Starts with 0 or 1 char showing. Some space between letters while scrolling. Stops when settled (having no extra space between word chars). Slow scroll, but not too slow (< 1s per iteration).
Example
Running script with arg 'Hello World'
H
later
H e l l o W o
later
H e l l o W o r l d
later
Hell o W o r l d
finally
Hello World
For a running example, try my code from the "Hello World" challenge. Eventually I will post mine. It currently is 202 chars in Perl. Now that there are some competitors, I have posted mine in the answers.
Winner
I don't want the restrictions to be absolute, that's why I left them a little vague. The shortest script which follows the spirit of my original will win.
Notes
This game assumes xterm
environment. Should another environment prove useful, only similar environments will be compared and a separate winner may be declared for each.
Addendum (April 25, 2012)
To address some budding issues, I'm making a ruling. Your character count must include code needed to:
- Flush STDOUT (Looking at you Ruby)
- Implement
sleep
with time delay of <1s (Looking at you Perl)
This may be done as command line switches to an interpreter, but those characters count in the total (sans surrounding whitespace).
xterm
,vt102
, ...? \$\endgroup\$