Thursday, August 14, 2003 [Tweets] [Favorites]

Today’s Shell Snippets

tower$ jot -w "%03u" -s " " 19 2
002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020
tower$ python -c "print ' '.join(['%03u' % i for i in xrange(2, 21)])"
002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020
tower$ perl -e 'print join(" ", map { sprintf("%03u", $_) } (2..20)), "\n"'
002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020

2 Comments

The folks at perlmonks are playing "golf" with your perl version.

http://www.perlmonks.org/index.pl?node_id=283960

Cool!

It looks like some of the versions add an extra space before the newline, which I think is cheating. :-)

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment