Re: Dlang Features You Would Like To Share

2017-04-13 Thread Dukc via Digitalmars-d
On Thursday, 13 April 2017 at 05:51:27 UTC, Dukc wrote: auto use(alias F, T)(T t){return F(t);} void main() { import std.stdio; foreach(i; 1 .. 11) { foreach(j; 1 .. 11) write((i * j).use!(x => x*x), " "); writeln; } } forgot three letters: auto use(alias F, T...)(T

Re: Dlang Features You Would Like To Share

2017-04-13 Thread Dukc via Digitalmars-d
On Thursday, 13 April 2017 at 11:16:46 UTC, crimaniak wrote: If fact you don't need any template to do this. Try the next: foreach(i; 1 .. 11) { foreach(j; 1 .. 11) write((x => x*x)(i * j), " "); writeln; } True, that's a good trick too. But I prefer the template at

Re: Dlang Features You Would Like To Share

2017-04-13 Thread bluecat via Digitalmars-d
On Thursday, 13 April 2017 at 11:16:46 UTC, crimaniak wrote: On Thursday, 13 April 2017 at 05:51:27 UTC, Dukc wrote: auto use(alias F, T)(T t){return F(t);} void main() { import std.stdio; foreach(i; 1 .. 11) { foreach(j; 1 .. 11) write((i * j).use!(x => x*x), " ");

Re: Dlang Features You Would Like To Share

2017-04-13 Thread Idan Arye via Digitalmars-d
On Wednesday, 12 April 2017 at 21:40:48 UTC, bluecat wrote: What are some features that you have discovered that you would like to share with the community? For me, one thing I found interesting was the ability to define structures dynamically using mixins: import std.stdio; import

Re: Dlang Features You Would Like To Share

2017-04-13 Thread crimaniak via Digitalmars-d
On Thursday, 13 April 2017 at 05:51:27 UTC, Dukc wrote: auto use(alias F, T)(T t){return F(t);} void main() { import std.stdio; foreach(i; 1 .. 11) { foreach(j; 1 .. 11) write((i * j).use!(x => x*x), " "); writeln; } } This way, you can avoid writing long expressions

Re: Dlang Features You Would Like To Share

2017-04-13 Thread Guillaume Piolat via Digitalmars-d
On Wednesday, 12 April 2017 at 21:40:48 UTC, bluecat wrote: What are some features that you have discovered that you would like to share with the community? For me, one thing I found interesting was the ability to define structures dynamically using mixins: import std.stdio; import

Re: Dlang Features You Would Like To Share

2017-04-12 Thread Dukc via Digitalmars-d
On Wednesday, 12 April 2017 at 21:40:48 UTC, bluecat wrote: What are some features that you have discovered that you would like to share with the community? auto use(alias F, T)(T t){return F(t);} void main() { import std.stdio; foreach(i; 1 .. 11) { foreach(j; 1 .. 11) write((i *

Re: Dlang Features You Would Like To Share

2017-04-12 Thread Stefan Koch via Digitalmars-d
On Wednesday, 12 April 2017 at 21:40:48 UTC, bluecat wrote: What are some features that you have discovered that you would like to share with the community? For me, one thing I found interesting was the ability to define structures dynamically using mixins: import std.stdio; import

Dlang Features You Would Like To Share

2017-04-12 Thread bluecat via Digitalmars-d
What are some features that you have discovered that you would like to share with the community? For me, one thing I found interesting was the ability to define structures dynamically using mixins: import std.stdio; import std.format: format; template MakePoint(string name, string x, string