Blog Post #0050: MVC III - ComboBoxText, Add & Remove

2019-07-05 Thread Ron Tarrant via Digitalmars-d-learn
Today is a bit of a milestone for the blog as the 50th regular post goes up. Also, the facelift is coming along nicely, the next phase of which should be ready to push by July 9th. And today's topic continues with the MVC series by demonstrating how to add and remove items from a ComboBoxText

Re: Blog Post #0050: MVC III - ComboBoxText, Add & Remove

2019-07-05 Thread matheus via Digitalmars-d-learn
On Friday, 5 July 2019 at 09:34:08 UTC, Ron Tarrant wrote: Today is a bit of a milestone for the blog as the 50th regular post goes up. Also, the facelift is coming along nicely, the next phase of which should be ready to push by July 9th. And today's topic continues with the MVC series by

Re: To learn D

2019-07-05 Thread Craig Dillabaugh via Digitalmars-d-learn
On Friday, 5 July 2019 at 12:00:15 UTC, Binarydepth wrote: I've considering learning full D. I remembered that D is not recommended as a first language, So I read time ago. So my question, is learning C and Python a good intro before learning D? TY Ali's book is targeted at beginners (see

Re: To learn D

2019-07-05 Thread Samir via Digitalmars-d-learn
On Friday, 5 July 2019 at 13:56:18 UTC, Craig Dillabaugh wrote: Ali's book is targeted at beginners (see link below). I don't see why D wouldn't make a good first language. If your objective is to learn D, then I don't think learning C or Python is going to be help that much. Obviously if

Re: Finding Max Value of Column in Multi-Dimesional Array

2019-07-05 Thread Samir via Digitalmars-d-learn
On Friday, 5 July 2019 at 01:41:38 UTC, 9il wrote: You may want to take a look into mir-algorithm [1] library. It contains ndsilce package [2] to work with multidimensional data. Thanks for referring me to this library, Ilya. I will have to check this out. While it seems a bit more

To learn D

2019-07-05 Thread Binarydepth via Digitalmars-d-learn
I've considering learning full D. I remembered that D is not recommended as a first language, So I read time ago. So my question, is learning C and Python a good intro before learning D? TY

Re: To learn D

2019-07-05 Thread Cym13 via Digitalmars-d-learn
On Friday, 5 July 2019 at 12:00:15 UTC, Binarydepth wrote: I've considering learning full D. I remembered that D is not recommended as a first language, So I read time ago. So my question, is learning C and Python a good intro before learning D? TY Both C and Python provide valuable and

Re: Why are immutable array literals heap allocated?

2019-07-05 Thread Max Haughton via Digitalmars-d-learn
On Friday, 5 July 2019 at 16:25:10 UTC, Nick Treleaven wrote: On Thursday, 4 July 2019 at 11:06:36 UTC, Eugene Wissner wrote: static immutable arr = [1, 2]; You have to spell it out that the data is static. Yes, I was wondering why the compiler doesn't statically allocate it

Re: Why are immutable array literals heap allocated?

2019-07-05 Thread Nick Treleaven via Digitalmars-d-learn
On Thursday, 4 July 2019 at 11:06:36 UTC, Eugene Wissner wrote: static immutable arr = [1, 2]; You have to spell it out that the data is static. Yes, I was wondering why the compiler doesn't statically allocate it automatically as an optimization.

Files as buffered InputRange

2019-07-05 Thread berni via Digitalmars-d-learn
I'd like to process a (binary) file as a buffered InputRange but I havn't found anything yet. Is there anything or do I have to write it on my own?

Re: Files as buffered InputRange

2019-07-05 Thread berni via Digitalmars-d-learn
On Friday, 5 July 2019 at 17:57:39 UTC, Les De Ridder wrote: File.byChunk[1] should do the trick. [1] https://dlang.org/library/std/stdio/file.by_chunk.html Not sure, if this is, what I'm looking for. I'd like to do something like buffered_file.map!(a=>2*a).writeln(); When I understand

Re: Finding Max Value of Column in Multi-Dimesional Array

2019-07-05 Thread Samir via Digitalmars-d-learn
On Friday, 5 July 2019 at 00:54:15 UTC, Samir wrote: Is there a cleaner way of finding the maximum value of say the third column in a multi-dimensional array than this? int[][] p = [[1,2,3,4], [9,0,5,4], [0,6,2,1]]; writeln([p[0][2], p[1][2], p[2][2]].max); I've tried the following writeln([0,

Re: Files as buffered InputRange

2019-07-05 Thread Les De Ridder via Digitalmars-d-learn
On Friday, 5 July 2019 at 18:29:36 UTC, berni wrote: On Friday, 5 July 2019 at 17:57:39 UTC, Les De Ridder wrote: File.byChunk[1] should do the trick. [1] https://dlang.org/library/std/stdio/file.by_chunk.html Not sure, if this is, what I'm looking for. I'd like to do something like

Re: Files as buffered InputRange

2019-07-05 Thread berni via Digitalmars-d-learn
On Friday, 5 July 2019 at 18:45:01 UTC, Les De Ridder wrote: On Friday, 5 July 2019 at 18:29:36 UTC, berni wrote: On Friday, 5 July 2019 at 17:57:39 UTC, Les De Ridder wrote: File.byChunk[1] should do the trick. [1] https://dlang.org/library/std/stdio/file.by_chunk.html Not sure, if this

Re: Finding Max Value of Column in Multi-Dimesional Array

2019-07-05 Thread ag0aep6g via Digitalmars-d-learn
On 05.07.19 20:49, Samir wrote: As a follow-on to my earlier question, is there a way to pass a variable to the `map` function that specifies the column, rather than hard-coding it?  I'm thinking of something like: p.map!("a[column]").maxElement.writeln; You can't do that with the string

Re: Finding Max Value of Column in Multi-Dimesional Array

2019-07-05 Thread dwdv via Digitalmars-d-learn
On 7/5/19 9:56 PM, ag0aep6g via Digitalmars-d-learn wrote: On 05.07.19 20:49, Samir wrote: As a follow-on to my earlier question, is there a way to pass a variable to the `map` function that specifies the column, rather than hard-coding it?  I'm thinking of something like:

Re: Files as buffered InputRange

2019-07-05 Thread Les De Ridder via Digitalmars-d-learn
On Friday, 5 July 2019 at 17:29:26 UTC, berni wrote: I'd like to process a (binary) file as a buffered InputRange but I havn't found anything yet. Is there anything or do I have to write it on my own? File.byChunk[1] should do the trick. [1]

Re: Blog Post #0050: MVC III - ComboBoxText, Add & Remove

2019-07-05 Thread Ron Tarrant via Digitalmars-d-learn
On Friday, 5 July 2019 at 13:52:40 UTC, matheus wrote: On Friday, 5 July 2019 at 09:34:08 UTC, Ron Tarrant wrote: Today is a bit of a milestone for the blog as the 50th regular post goes up. Also, the facelift is coming along nicely, the next phase of which should be ready to push by July 9th.

Re: Finding Max Value of Column in Multi-Dimesional Array

2019-07-05 Thread dwdv via Digitalmars-d-learn
On 7/5/19 9:56 PM, ag0aep6g via Digitalmars-d-learn wrote: On 05.07.19 20:49, Samir wrote: As a follow-on to my earlier question, is there a way to pass a variable to the `map` function that specifies the column, rather than hard-coding it?  I'm thinking of something like:

Re: Why are immutable array literals heap allocated?

2019-07-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 5, 2019 10:25:10 AM MDT Nick Treleaven via Digitalmars-d- learn wrote: > On Thursday, 4 July 2019 at 11:06:36 UTC, Eugene Wissner wrote: > > static immutable arr = [1, 2]; > > > > You have to spell it out that the data is static. > > Yes, I was wondering why the compiler

Re: Why are immutable array literals heap allocated?

2019-07-05 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 4 July 2019 at 10:56:50 UTC, Nick Treleaven wrote: immutable(int[]) f() @nogc { return [1,2]; } onlineapp.d(2): Error: array literal in `@nogc` function `onlineapp.f` may cause a GC allocation This makes dynamic array literals unusable with @nogc, and adds to GC pressure

Re: Why are immutable array literals heap allocated?

2019-07-05 Thread Patrick Schluter via Digitalmars-d-learn
On Friday, 5 July 2019 at 23:08:04 UTC, Patrick Schluter wrote: On Thursday, 4 July 2019 at 10:56:50 UTC, Nick Treleaven wrote: immutable(int[]) f() @nogc { return [1,2]; } onlineapp.d(2): Error: array literal in `@nogc` function `onlineapp.f` may cause a GC allocation This makes

Re: Why are immutable array literals heap allocated?

2019-07-05 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 5 July 2019 at 16:25:10 UTC, Nick Treleaven wrote: Yes, I was wondering why the compiler doesn't statically allocate it automatically as an optimization. Which i would think it could, but silently adds .dup to the end as it points to a unnamed memory block of N size. Or if it's