I've started reading a Python tutorial and this is the first little script I wrote :
#!/usr/bin/env python a="internationalization" print a[0] + str(len(a[1:-1])) + a[-1] a="localization" print a[0] + str(len(a[1:-1])) + a[-1]
If it is executed, you get :
i18n l10n
It's not much, but slightly less boring than the usual "Hello World!".
Basically, it just takes the first and last character of each word, and replaces the characters in between with the total number of characters in between. The exciting thing about it, is the sheer compactness of the syntax. In any other language a lot more code would be needed. :)
BTW : i18n and l10n are widely used numeronyms, that refer to internationalization and localization.
2 comments:
Indeed, in C# you have to type more...
var a = "internationalization";
System.Console.WriteLine(a[0] + a.Substring(1, a.ToCharArray().GetUpperBound(0) - 1).Length.ToString() + a[a.Length - 1]);
a = "localization";
System.Console.WriteLine(a[0] + a.Substring(1, a.ToCharArray().GetUpperBound(0) - 1).Length.ToString() + a[a.Length - 1]);
In PHP:
$a = 'internationalization';
echo $a{0}.(strlen($a)-2).substr($a, -1);
Post a Comment