Re: Reading a file of words line by line

2020-01-15 Thread Jesse Phillips via Digitalmars-d-learn
On Wednesday, 15 January 2020 at 19:50:31 UTC, mark wrote: I really do need a set for the next part of the program, but taking your code and ideas I have now reduced the function to this: WordSet getWords(string filename, int wordsize) { WordSet words; File(filename).byLine .ma

Re: Some comments on learning D using the tour

2020-01-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 15 January 2020 at 20:06:01 UTC, mark wrote: For example, I haven't found one definitive place in the docs that document D's strings. My unofficial docs are built from the same source, so not perfect, but at least have better cross linking: http://dpldocs.info/experimental-docs

Re: Some comments on learning D using the tour

2020-01-15 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 15 January 2020 at 20:06:01 UTC, mark wrote: However, what I really miss is a contents page so that I can look at each topic and jump back when I want to recap something. Please submit an enhancement request: https://github.com/dlang-tour/core/issues For example, I haven't f

Re: Reading a file of words line by line

2020-01-15 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 15, 2020 at 07:50:31PM +, mark via Digitalmars-d-learn wrote: [...] > Why did you use string.count rather than string.length? The .length of a `string` type is the number of bytes that it occupies, which is not necessarily the same thing as the number of characters in the string. E

Some comments on learning D using the tour

2020-01-15 Thread mark via Digitalmars-d-learn
I am learning D for the first time. While I wait for Mike Parker's "Learning D" book to arrive, I have started using the tour. I really like the tour, especially the fact that you can run and tweak the code as well as read the explanations. However, what I really miss is a contents page so

Re: Reading a file of words line by line

2020-01-15 Thread mark via Digitalmars-d-learn
I really do need a set for the next part of the program, but taking your code and ideas I have now reduced the function to this: WordSet getWords(string filename, int wordsize) { WordSet words; File(filename).byLine .map!(line => line.until!(not!isAlpha)) .filter!(word =

Re: Get memory used by current process at specific point in time

2020-01-15 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-01-15 19:45, Chris Katko wrote: Still, some internal instrumentation would be nice. But I'm not aware of any. There are some runtime flags that can be passed to the executable when running it to get some info about the GC. Of course these are not documented (except perhaps in the cha

Re: Get memory used by current process at specific point in time

2020-01-15 Thread Chris Katko via Digitalmars-d-learn
On Sunday, 12 January 2020 at 13:58:18 UTC, Per Nordlöw wrote: Is there a druntime/phobos function for getting the amount of memory (both, stack, malloc, and GC) being used by the current process? Valgrind will tell you the exact usage (except no delineation for GC) per here: https://stacko

Re: Reading a file of words line by line

2020-01-15 Thread dwdv via Digitalmars-d-learn
On 2020-01-15 16:34, mark via Digitalmars-d-learn wrote: Is this as compact as it _reasonably_ can be? How about this? auto uniqueWords(string filename, uint wordsize) { import std.algorithm, std.array, std.conv, std.functional, std.uni; return File(filename).byLine .map!(line

Re: How to create meson.build with external libs?

2020-01-15 Thread 9il via Digitalmars-d-learn
On Sunday, 12 January 2020 at 22:00:33 UTC, p.shkadzko wrote: Ok, I am trying to meson and is struggling with meson.build file. I looked up the examples page: https://github.com/mesonbuild/meson/tree/master/test%20cases/d which has a lot of examples but not the one that shows you how to build

Re: Practical parallelization of D compilation

2020-01-15 Thread Guillaume Lathoud via Digitalmars-d-learn
Concerning the first (fresh) compilation: On Wednesday, 8 January 2020 at 13:14:38 UTC, kinke wrote: [...] you can also try to compile all modules at once, but output separate object files - `ldc2 -c a.d b.d c.d`. I just had another try at `ldc2 -c ...`. It does work when grouping the files i

Re: sdl 2 - text is not displayed correctly

2020-01-15 Thread drug via Digitalmars-d-learn
On 1/15/20 6:26 PM, TodNaz wrote: Hello! Maybe someone came across ... I use sdl 2 derelcit, and wanted to draw text (not English, but Russian, for example). And when called in TTF_RenderUTF8_Blended, the text is drawn with incorrect characters (with these: ""). And with wstribg and TTF_Render

Re: range algorithms on container class

2020-01-15 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 9 January 2020 at 10:26:07 UTC, Jonathan M Davis wrote: On Wednesday, January 8, 2020 10:56:20 PM MST rikki cattermole via Digitalmars-d-learn wrote: Slicing via the opSlice operator overload is a convention, not a requirement. It's not a requirement, but it's more than a conventi

Re: Reading a file of words line by line

2020-01-15 Thread mark via Digitalmars-d-learn
Thanks for the ideas, I've now reduced the size of the getWords() function (even allowing for moving the imports to the top of the file) to this: WordSet getWords(string filename, int wordsize) { string bareWord(string line) { auto rx = ctRegex!(r"^([a-z]+)", "i"); auto matc

sdl 2 - text is not displayed correctly

2020-01-15 Thread TodNaz via Digitalmars-d-learn
Hello! Maybe someone came across ... I use sdl 2 derelcit, and wanted to draw text (not English, but Russian, for example). And when called in TTF_RenderUTF8_Blended, the text is drawn with incorrect characters (with these: ""). And with wstribg and TTF_RendererUNICODE_Blended, the surface has

How to use -profile when I initialize D-runtime myself?

2020-01-15 Thread Robert M. Münch via Digitalmars-d-learn
Hi, I had a related question in the "Does -profile need the D runtime?" thread. Since D runtime is required for profile to work, the question is how can I use profile when initializing it myself? -- Robert M. Münch http://www.saphirion.com smarter | better | faster

Re: Invalid memory operation during allocation with `new`

2020-01-15 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 13 January 2020 at 23:06:01 UTC, Per Nordlöw wrote: Unfortunately that didn't tell me the cause of the problem but only the stack trace of the failing call to `new` which is not called inside a destructor. I found the problem. I was greedly using the `__monitor__` slot of some clas

Re: range algorithms on container class

2020-01-15 Thread Ali Çehreli via Digitalmars-d-learn
On 1/14/20 8:15 PM, Alex Burton wrote:> On Thursday, 9 January 2020 at 10:26:07 UTC, Jonathan M Davis wrote: >> On Wednesday, January 8, 2020 10:56:20 PM MST rikki cattermole via >> Digitalmars-d-learn wrote: >>> Slicing via the opSlice operator overload is a convention, not a >>> requirement. >>