Re: How come a count of a range becomes 0 before a foreach?

2023-04-10 Thread ikelaiah via Digitalmars-d-learn
On Monday, 10 April 2023 at 01:01:59 UTC, Steven Schveighoffer wrote: On 4/9/23 9:16 AM, Ali Çehreli wrote: On 4/8/23 21:38, ikelaiah wrote: > I will modify the code to construct it twice. Multiple iterations of dirEntries can produce different results, which may or may not be what your

Re: How come a count of a range becomes 0 before a foreach?

2023-04-10 Thread ikelaiah via Digitalmars-d-learn
On Sunday, 9 April 2023 at 13:16:51 UTC, Ali Çehreli wrote: On 4/8/23 21:38, ikelaiah wrote: > I will modify the code to construct it twice. Multiple iterations of dirEntries can produce different results, which may or may not be what your program will be happy with. Sticking an .array at

Re: How come a count of a range becomes 0 before a foreach?

2023-04-08 Thread ikelaiah via Digitalmars-d-learn
On Sunday, 9 April 2023 at 03:39:52 UTC, Steven Schveighoffer wrote: On 4/8/23 9:38 PM, ikelaiah wrote: // Get files in specified inputPath variable with a specific extension     auto rmdFiles = file.dirEntries(inputPath, file.SpanMode.shallow)     .filter!(f => f.isFile)    

How come a count of a range becomes 0 before a foreach?

2023-04-08 Thread ikelaiah via Digitalmars-d-learn
Hi, I've written a file that converts Rmd (R Markdown file), to a MarkDown file. All works well if and only if line 73 is commented out. I marked line 72 in the code below. If line 73 is not commented out, `foreach` does not execute as the `rmdFiles.walklength` in line 82 becomes `0`.

Re: My new programming book ...

2022-11-06 Thread ikelaiah via Digitalmars-d-learn
On Monday, 7 November 2022 at 00:55:33 UTC, zjh wrote: Is there a second edition? After all, it has been many years. Hi zjh, I'm aware of the publication date. However, I find the content still highly relevant to many day-to-day tasks (my use case). No doubt, there will be new features in

My new programming book ...

2022-11-06 Thread ikelaiah via Digitalmars-d-learn
Hi, I got a new programming book yesterday, authored by Adam D. Rupee. ![new-book](https://www.linkpicture.com/q/20221106_142031_1.jpg). I'm still in **Chapter 1**, on the matter of `Immutable` variables. Can't wait to read **Chapter 7** on **Corectness and Documentation**. So far, I

Re: Main foreach loop fails when another foreach is added

2022-08-07 Thread ikelaiah via Digitalmars-d-learn
On Monday, 8 August 2022 at 02:45:54 UTC, Steven Schveighoffer wrote: And now, you tried to read it again! Which means you are trying to read more data from an empty stream. You need to either a) reopen the file, or b) do both in the same loop. -Steve Steve! You are Legend! **Thank

Main foreach loop fails when another foreach is added

2022-08-07 Thread ikelaiah via Digitalmars-d-learn
Hi, I'm writing a program that reads a text file and launch my work URLs in it. It worked fine, and very happy. Then I added another `foreach` loop to count total number of lines. After this, the main `foreach` won't work. Does anyone know as to why this happens? I might have missed

Re: Combining JSON arrays into a single JSON array -- better way than this?

2022-08-01 Thread ikelaiah via Digitalmars-d-learn
On Monday, 1 August 2022 at 17:02:10 UTC, Salih Dincer wrote: When printing the steps `import std.stdio : writeln;` use it. Thus, it does not conflict with `std.file`. SDB@79 Will do and thank you for this.

Re: Combining JSON arrays into a single JSON array -- better way than this?

2022-08-01 Thread ikelaiah via Digitalmars-d-learn
On Monday, 1 August 2022 at 16:11:52 UTC, frame wrote: ... because loading all in memory while not necessary is wasted memory if you have large files to process. Noted with thanks. Actually, some JSON input files are pretty large (>1Mb). I would just process each file and write it to the

Re: Combining JSON arrays into a single JSON array -- better way than this?

2022-08-01 Thread ikelaiah via Digitalmars-d-learn
On Monday, 1 August 2022 at 05:52:36 UTC, frame wrote: If the JSON files are already parsed, why you stringify and reparse it? Because of ... 1. mental block and 2. I didn't know `jsonResult.array = [];` Many thanks for pointing this out. I tried the following, and didn't work, and

Re: Combining JSON arrays into a single JSON array -- better way than this?

2022-08-01 Thread ikelaiah via Digitalmars-d-learn
On Monday, 1 August 2022 at 07:35:34 UTC, Christian Köstlin wrote: An arguably shorter solution (that drops some of your logging) could be: ```d import std; void main() { dirEntries(".", "*.json", SpanMode.shallow) .filter!(f => !f.name.canFind("output")) .map!(readText)

Combining JSON arrays into a single JSON array -- better way than this?

2022-07-31 Thread ikelaiah via Digitalmars-d-learn
Hi, I've written a cli tool to merge JSON files (containing JSON array) in the current folder as a single JSON file. My algorithm: 1. Create a string to store the output JSON array as a string, 2. read each file 3. read each object in JSON array from input file 4. append the string