|
|
|
|
|
by 0xcoffee
2472 days ago
|
|
Obligatory C#: var input = new string[] { "abc", "ab", "abcdef", "abcdefgh" };
var maxLength = input.Select(e => e.Length).Max();
var output = input.Select(e =>
{
var padding = (maxLength - e.Length) / 2;
return new String(' ', padding) + e;
});
Most modern `oop` languages these days all support functional constructs and achieve the same thing in same amount of code & style. Language and oop/functional style are not mutually exclusive anymore, which this article seems to overlook by comparing both languages and styles at the same time. |
|