TypeFunction example: ImplictConvTargets
Daniel K
dkm4i1 at gmail.com
Wed Oct 7 02:10:03 UTC 2020
On Wednesday, 7 October 2020 at 01:07:17 UTC, claptrap wrote:
> On Tuesday, 6 October 2020 at 23:39:24 UTC, H. S. Teoh wrote:
>> On Tue, Oct 06, 2020 at 11:16:47PM +0000, claptrap via
>> Digitalmars-d wrote: [...]
>>>
>> I would write it like this:
>>
>> int[] vals = [4,7,28,23,585,73,12];
>>
>> int[] getMultiplesOf(int i)
>> {
>> return vals.filter!(v => (v % i) == 0).array;
>> }
>>
>> One line vs. 4, even more concise. ;-)
>
> The point is to show language not library.
>
>
>> Thing is, what someone finds intuitive or not, is a pretty
>> subjective matter, and depends on what programming style he's
>> familiar with and/or prefers. What a C programmer finds
>> readable and obvious may be needlessly arcane to a Java
>> programmer, and what an APL programmer finds totally obvious
>> may be completely impenetrable to anyone else. :-P
>
> We're not looking for "is this intuitive to Java programmers",
> we're asking is this intuitive to D programmers, so if they
> already know D then *you have context* in which to judge
> whether it's intuitive or not. And "It's just like regular D
> code but with types" pretty much hits the nail on the head as
> fair as intuitive goes.
If recursive templates are not intuitive to you, perhaps you
still have more D to learn, to become this mythical "D
programmer".
My 16 lines of template essentially compiled in D for at least
the past 10 years.
It literally is "regular D code".
If recursion and declarative programming isn't intuitive to you
in general, then perhaps that's not D's problem at all.
/Daniel K
More information about the Digitalmars-d
mailing list