Programming Perls Rewritten in Ruby

Just for a little exercise i am doing the programming pearls examples/tasks in ruby, and so far it has been funny/challenging.
Source is on github

Trivial examples

#displaying all words from STDIN
#C++
int main(void)
{   set S;
    set::iterator j;
    string t;
    while (cin >> t)
        S.insert(t);
    for (j = S.begin(); j != S.end(); ++j)
        cout << *j << "\n";
    return 0;
}

#Ruby
puts STDIN.readlines(' ').uniq * "\n"

ruby is my winner 😀

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s