Thursday, August 14, 2003

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 RSS · Twitter

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. :-)

Leave a Comment