Covariance for []

2023-01-19 Thread davemo via Digitalmars-d-learn
Hello, I was wondering why the following code does not compile. ```d import std; abstract class Range(T) { abstract T back(); abstract bool empty(); abstract T front(); abstract void popBack(); abstract void popFront(); } class RangeWrapper(TRange) :

Re: Are there more up-to-date D template tutorials?

2023-01-19 Thread bachmeier via Digitalmars-d-learn
On Thursday, 19 January 2023 at 04:22:21 UTC, thebluepandabear wrote: Help would be appreciated. Regards, thebluepandabear A bit off topic/ranty but I did find the book by Ali on D extremely useful, but it was good as an 'introduction'. I feel like when it comes to more advanced features

Re: Are there more up-to-date D template tutorials?

2023-01-19 Thread SealabJaster via Digitalmars-d-learn
On Thursday, 19 January 2023 at 04:22:21 UTC, thebluepandabear wrote: ... I also wrote this article[1] recently exploring how one of my D libraries make use of templates and metaprogramming. Unfortuantely the LinkedIn editor is complete trash and I got to the point any change at all would

Re: Why not allow elementwise operations on tuples?

2023-01-19 Thread Sergei Nosov via Digitalmars-d-learn
On Wednesday, 18 January 2023 at 16:42:00 UTC, JG wrote: I guess such a method wouldn't be particularly generic since a tuple does not need to consist of types that have the same operations e.g. Tuple!(int,string) etc That's where `areCompatibleTuples` function comes in!

Re: Are there more up-to-date D template tutorials?

2023-01-19 Thread SealabJaster via Digitalmars-d-learn
On Thursday, 19 January 2023 at 04:22:21 UTC, thebluepandabear wrote: ... I presented a talk[1] at Dconf online 2021, which may or may not be what you're looking for. I know my mic audio is pretty bad, but honestly the slides themselves have all the information you need, so you can just

Re: Covariance for []

2023-01-19 Thread davemo via Digitalmars-d-learn
On Thursday, 19 January 2023 at 12:54:39 UTC, davemo wrote: Hello, I was wondering why the following code does not compile. ```d import std; [...] It looks like the following change works fine. ```d Range!A as() { return wrap(_bs.map!((b) { return cast(A) b; })); } ```

Re: Pyd examples or resources for Python 3.x

2023-01-19 Thread Sergey via Digitalmars-d-learn
On Friday, 20 January 2023 at 00:39:47 UTC, Seamus wrote: Howdy folks Honestly in my opinion PyD looks kinda abounded. I don’t know how much effort you need to spend to run spaCy. Just to be sure that you’ve seen this documentation https://pyd.readthedocs.io/en/latest/index.html Also

Re: How to Add CSS and JS to vibe.d templates

2023-01-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/19/23 11:44 PM, seany wrote: Hi Howcan one add CSS and JS to vibe.d templates? Here is my setup (vibe.d project initiated with dub using dub init myproject vibe.d): ./public: main.css  main.js ./source: app.d ./views: auth2fa.dt  fail.dt  login.dt  pair.dt  passfail.dt  userfail.dt

Re: Are there more up-to-date D template tutorials?

2023-01-19 Thread thebluepandabear via Digitalmars-d-learn
roduct/learning-d/9781783552481?_ga=2.241359490.1811075590.1674153096-1605518740.1674153096 or Adam's book https://www.packtpub.com/product/d-cookbook/9781783287215?_ga=2.198287279.1811075590.1674153096-1605518740.1674153096 They're older than 2019, but I don't think much of the material

What is the 'Result' type even for?

2023-01-19 Thread Ruby The Roobster via Digitalmars-d-learn
Take this example: ```d import std; void main() { auto c = "a|b|c|d|e".splitter('|'); c.writeln; string[] e = ["a", "b", "c", "d", "e"]; assert(c.equal(e)); typeof(c).stringof.writeln; } ``` The program prints: ["a", "b", "c", "d", "e"] Result What is the purpose of this

Re: What is the 'Result' type even for?

2023-01-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/19/23 10:11 PM, Ruby The Roobster wrote: Take this example: ```d import std; void main() {     auto c = "a|b|c|d|e".splitter('|');     c.writeln;     string[] e = ["a", "b", "c", "d", "e"];     assert(c.equal(e));     typeof(c).stringof.writeln; } ``` The program prints: ["a", "b",

Re: What is the 'Result' type even for?

2023-01-19 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 20, 2023 at 03:11:33AM +, Ruby The Roobster via Digitalmars-d-learn wrote: > Take this example: > > ```d > import std; > void main() > { > auto c = "a|b|c|d|e".splitter('|'); > c.writeln; > string[] e = ["a", "b", "c", "d", "e"]; > assert(c.equal(e)); >

Re: What is the 'Result' type even for?

2023-01-19 Thread Ruby The Roobster via Digitalmars-d-learn
On Friday, 20 January 2023 at 03:30:56 UTC, Steven Schveighoffer wrote: On 1/19/23 10:11 PM, Ruby The Roobster wrote: ... The point is to be a range over the original input, evaluated lazily. Using this building block, you can create an array, or use some other algorithm, or whatever you

How to Add CSS and JS to vibe.d templates

2023-01-19 Thread seany via Digitalmars-d-learn
Hi Howcan one add CSS and JS to vibe.d templates? Here is my setup (vibe.d project initiated with dub using dub init myproject vibe.d): ./public: main.css main.js ./source: app.d ./views: auth2fa.dt fail.dt login.dt pair.dt passfail.dt userfail.dt I am trying to add a css file

Re: What is the 'Result' type even for?

2023-01-19 Thread Ali Çehreli via Digitalmars-d-learn
On 1/19/23 19:11, Ruby The Roobster wrote: > typeof(c).stringof.writeln; > The program prints: > > ["a", "b", "c", "d", "e"] > Result > > What is the purpose of this 'Result' type? Just to make sure, 'Result' is what the programmer of a Phobos algorithm chose to name a struct type. It

Re: Pyd examples or resources for Python 3.x

2023-01-19 Thread bachmeier via Digitalmars-d-learn
On Friday, 20 January 2023 at 00:39:47 UTC, Seamus wrote: Howdy folks I am new around these parts and looking forward to getting stuck into some D development. Really liking it so far, just one some questions though... I am working on a project that did not sit well with me when I tried it

Re: What is the 'Result' type even for?

2023-01-19 Thread Ruby The Roobster via Digitalmars-d-learn
On Friday, 20 January 2023 at 03:11:33 UTC, Ruby The Roobster wrote: Take this example: ```d import std; void main() { auto c = "a|b|c|d|e".splitter('|'); c.writeln; string[] e = ["a", "b", "c", "d", "e"]; assert(c.equal(e)); typeof(c).stringof.writeln; } ``` The program

Re: What is the 'Result' type even for?

2023-01-19 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 20 January 2023 at 03:11:33 UTC, Ruby The Roobster wrote: What is the purpose of this 'Result' type? To serve as a generic range? Because, it seems to only cause problems... No. When I first started learning this language, I thought the same thing. However, such a designm

Vibe.d Diet Templatesand Forms

2023-01-19 Thread seany via Digitalmars-d-learn
Hello Please consider this diet template: doctype html html(lang="es", dir="ltr") head meta(name="viewport", content="width=device-width, user-scalable=no, initial-scale=1.0") meta(charset="utf-8")

Re: Vibe.d Diet Templatesand Forms

2023-01-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/19/23 6:24 PM, seany wrote: Hello Please consider this diet template:     doctype html     html(lang="es", dir="ltr")     head     meta(name="viewport", content="width=device-width, user-scalable=no, initial-scale=1.0")    

Re: Vibe.d Diet Templatesand Forms

2023-01-19 Thread seany via Digitalmars-d-learn
On Friday, 20 January 2023 at 01:32:04 UTC, Steven Schveighoffer wrote: On 1/19/23 6:24 PM, seany wrote: [...] Did you mean to include straight HTML here? I don't think that is supported. [...] You are indeed right. The Link was a problem, and removing the link actually have sorted the

Pyd examples or resources for Python 3.x

2023-01-19 Thread Seamus via Digitalmars-d-learn
Howdy folks I am new around these parts and looking forward to getting stuck into some D development. Really liking it so far, just one some questions though... I am working on a project that did not sit well with me when I tried it in Python. I need static typing (above and beyond MyPy, as

Re: What is the 'Result' type even for?

2023-01-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/19/23 10:34 PM, Ruby The Roobster wrote: On Friday, 20 January 2023 at 03:30:56 UTC, Steven Schveighoffer wrote: On 1/19/23 10:11 PM, Ruby The Roobster wrote: ... The point is to be a range over the original input, evaluated lazily. Using this building block, you can create an array, or

Re: What is the 'Result' type even for?

2023-01-19 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 20, 2023 at 03:34:43AM +, Ruby The Roobster via Digitalmars-d-learn wrote: > On Friday, 20 January 2023 at 03:30:56 UTC, Steven Schveighoffer wrote: > > On 1/19/23 10:11 PM, Ruby The Roobster wrote: > > ... > > > > The point is to be a range over the original input, evaluated > >

Re: What is the 'Result' type even for?

2023-01-19 Thread Basile B. via Digitalmars-d-learn
On Friday, 20 January 2023 at 03:11:33 UTC, Ruby The Roobster wrote: Take this example: [...] What is the purpose of this 'Result' type? To serve as a generic range? Yes this is a lazy input range. Use `.array` to yield directly as a concrete value, then you can append using `~=`. Note