What does ! Stand for in map! and filter! function calls?
Rnd
r_narang at yahoo.com
Sun Jun 2 16:39:57 UTC 2019
On Sunday, 2 June 2019 at 15:55:46 UTC, Paul Backus wrote:
> On Sunday, 2 June 2019 at 15:48:54 UTC, Rnd wrote:
>> I have recently started using Dlang, hence this basic
>> question. Thanks for your insight.
>
> map and filter are templates in D, and !(...) is D's syntax for
> passing arguments to templates:
>
> map!(x => x*x)([1, 2, 3, 4, 5])
> ^ ^
> | |
> | +- This array is a normal function argument
> |
> +- This lambda is a template argument
Is it not possible in the language to have template map function
also to called as map(x=>... ?
This will reduce complexity which will attract more people to
this language.
Easy languages have great mass appeal as has been shown with Ruby
and Python.
More information about the Digitalmars-d-learn
mailing list