Re: Templates and unaryFun!

2020-09-24 Thread ddcovery via Digitalmars-d-learn
I think I will dedicate tonight one or two hours to understand the first two proposals :-D. On Thursday, 24 September 2020 at 13:28:25 UTC, WebFreak001 wrote: [...] Alternatively a lot easier would be to just return auto and do: auto dt(alias fun, T)(Dot!T t){ return t.dot(t => unaryFu

Re: Templates and unaryFun!

2020-09-24 Thread ddcovery via Digitalmars-d-learn
On Thursday, 24 September 2020 at 14:15:01 UTC, ddcovery wrote: [...] I think I will dedicate tonight one or two hours to understand the first two proposals :-D. [...] Not necessary, really simple and well explained WebFreak001!!!

Re: Templates and unaryFun!

2020-09-24 Thread WebFreak001 via Digitalmars-d-learn
On Thursday, 24 September 2020 at 11:15:11 UTC, ddcovery wrote: [...] Example: I tried with a global function Dot!R dt(alias fun, T, R)(Dot!T t){ auto f = cast(R function(T)) unaryFun!fun; return t.dot!R(f); } [...] the problem is the template can't automatically determine the type "R". A

Templates and unaryFun!

2020-09-24 Thread ddcovery via Digitalmars-d-learn
Last week, in general forum someone introduced the possibility to implement the .? operator in D: https://forum.dlang.org/thread/blnjoaleswqnaojou...@forum.dlang.org I decided to implement a simple solution with a funciontal syntax: string fatherName = dot(person).dot(a=>a.father).dot(a=>a.na