Hi,
As i get better writing ruby scripts (im pretty new), I often wonder
if im not exploiting the power of the language or that i’m casting
precedural language ideas onto my ruby scripts. I have here a little C
program that would like some of you to Rubi-tize if possible, so that
i can see how some of you that really know the language use it.
[code]============================================
#include <stdio.h>
#include <stdlib.h>
int I;
/-----------------------------/
void dodot(int x){
while(x>0){
printf(" “);
x–;
}
printf(”\n");
sleep(10);
}
/-----------------------------*/
int main(int argc, char *argv[])
{
while(1){
while(I<75){
dodot(I);
I++;
}
while(I>0){
dodot(I);
I–;
}
}
return 0;
}
[/code]=============================================
Here is my unimaginitive attempt.
==============================================
WIDTH=78;
def do_dot(i)
i.times{print " "}
puts "*";
end
loop{
0.upto(WIDTH-1){|i|
do_dot(i);
}
WIDTH.downto(1){|i|
do_dot(i);
}
}
=============================================
Thanks.