On 05/09/2017 01:17 AM, k-five wrote:
> On Monday, 8 May 2017 at 21:37:17 UTC, Ali Çehreli wrote:
>> On 05/06/2017 02:24 AM, Stanislav Blinov wrote:
>> ------------------------------------------------
>
> It may D has this philosophy as Perl has: There's more than one way to
> do it
D certainly does not have such a philosophy. :)
> I found more than 5 ways.
>
> another way:
>
> string[] input = [ "", "", "", "", "" ]; // reserve for 5 elements
> args[ 1 ].split( '/' ).remvoe!( element => element.empty ).copy( input );
D does not try to limit the programmer but there aren't many ways of
reading a line. Note that the difference in the above case is what the
programmer is doing with the results. For example, copying the splitted
lines into a pre-existing array should not count as a different way.
Plus, wrapping steps of the same sollution in a function should not
count as a different way. Otherwise, we can have infinite number of ways
of doing the same things. For example, not!empty is the equivalent of
the following function:
auto notEmpty_0(T)(T a) {
return !a.empty;
}
Change 0 above to 1, 2, ... :)
Ali