fold on empty range

2021-02-17 Thread Rumbu via Digitalmars-d-learn
In the expression below: return matchAll(content, keywordsPattern) .map!(a => a.hit.stripLeft("[").strip("]")) .fold!((a, b) => a ~ "," ~ b) .splitter(',') .map!(a => a.stripLeft("\" ").strip("\" ")) .filter!(a => !a.any!(b => b == ' '

Re: fold on empty range

2021-02-17 Thread Rumbu via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 10:15:10 UTC, Mitacha wrote: it'll use empty string as first element in range. BTW perheps you could use `joinner` instead of this `fold` to join values with ",". Thanks for that. I thought to joiner too, but it doesn't work. I need fold to take a list of

Re: fold on empty range

2021-02-17 Thread Mitacha via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 09:21:47 UTC, Rumbu wrote: In the expression below: return matchAll(content, keywordsPattern) .map!(a => a.hit.stripLeft("[").strip("]")) .fold!((a, b) => a ~ "," ~ b) .splitter(',') .map!(a => a.stripLeft("\"

Re: std.typecons rebindable + tuple with const class gives warning

2021-02-17 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 4 February 2021 at 20:40:43 UTC, tsbockman wrote: TLDR; Either make `c` mutable, or override/overload the `C` associative array support methods `toHash` and `opEquals` to support `const(C)` objects. This solved my issue. I finally understood why this was happening after

Re: Web crawler/scraping

2021-02-17 Thread Carlos Cabral via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 12:27:16 UTC, Ferhat Kurtulmuş wrote: On Wednesday, 17 February 2021 at 12:12:56 UTC, Carlos Cabral wrote: Hi, I'm trying to collect some json data from a website/admin panel automatically, which is behind a login form. Is there a D library that can help me

Re: Web crawler/scraping

2021-02-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 12:12:56 UTC, Carlos Cabral wrote: I'm trying to collect some json data from a website/admin panel automatically, which is behind a login form. Does the website need javascript? If not, my dom.d may be able to help. It can download some HTML, parse it, fill

Re: fold on empty range

2021-02-17 Thread Rumbu via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 12:58:29 UTC, Mitacha wrote: On Wednesday, 17 February 2021 at 11:38:45 UTC, Rumbu wrote: [...] If you replace `fold` and `splitter` with this, then it doesn't allocate: ``` auto fn() @nogc { return only("k1,k2", "k3,k4") .map!(x =>

Re: is it posible to compile individual module separately?

2021-02-17 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 16 February 2021 at 18:54:08 UTC, Paul Backus wrote: I stand corrected. Shouldn't have trusted the documentation so much, I guess. It makes perfect sense to intuit that --single should be related to --build-mode=singleFile. As it is the build modes aren't explained in the

Re: Struct delegate access corruption

2021-02-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/17/21 10:38 AM, z wrote: So i've upgraded one of my structs to use the more flexible delegates instead of function pointers but when the member function tries to access the struct's members, the contents are random and the program fails. i've isolated the problem by adding writefln calls

Web crawler/scraping

2021-02-17 Thread Carlos Cabral via Digitalmars-d-learn
Hi, I'm trying to collect some json data from a website/admin panel automatically, which is behind a login form. Is there a D library that can help me with this? Thank you

Re: Web crawler/scraping

2021-02-17 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 12:12:56 UTC, Carlos Cabral wrote: Hi, I'm trying to collect some json data from a website/admin panel automatically, which is behind a login form. Is there a D library that can help me with this? Thank you I found this but it looks outdated:

Re: fold on empty range

2021-02-17 Thread Mitacha via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 11:38:45 UTC, Rumbu wrote: On Wednesday, 17 February 2021 at 10:15:10 UTC, Mitacha wrote: it'll use empty string as first element in range. BTW perheps you could use `joinner` instead of this `fold` to join values with ",". Thanks for that. I thought to

Re: Web crawler/scraping

2021-02-17 Thread Carlos Cabral via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 13:13:00 UTC, Adam D. Ruppe wrote: On Wednesday, 17 February 2021 at 12:12:56 UTC, Carlos Cabral wrote: I'm trying to collect some json data from a website/admin panel automatically, which is behind a login form. Does the website need javascript? If not, my

Struct delegate access corruption

2021-02-17 Thread z via Digitalmars-d-learn
So i've upgraded one of my structs to use the more flexible delegates instead of function pointers but when the member function tries to access the struct's members, the contents are random and the program fails. i've isolated the problem by adding writefln calls before calling the delegate

Re: How to get output of piped process?

2021-02-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/17/21 1:58 AM, Jedi wrote: I an using pipeShell, I have redirected stdout, stderr, and stdin. I am trying to read from the output and display it in my app. I have followed this code almost exactly except I use try wait and flush because the app is continuously updating the output. (it

Re: Web crawler/scraping

2021-02-17 Thread Carlos Cabral via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 13:13:00 UTC, Adam D. Ruppe wrote: On Wednesday, 17 February 2021 at 12:12:56 UTC, Carlos Cabral wrote: I'm trying to collect some json data from a website/admin panel automatically, which is behind a login form. Does the website need javascript? If not, my

Re: Struct delegate access corruption

2021-02-17 Thread tsbockman via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 17:45:01 UTC, H. S. Teoh wrote: I.e., the following is NOT a good idea: struct S { void delegate() member; this() { member = } private void impl(); }

null and initialized string comparisons

2021-02-17 Thread Martin via Digitalmars-d-learn
Hi, is this how it supposed to be? (https://run.dlang.io/is/7B4irm) --- string a = null; string t = ""; assert( ! a ); assert( t ); assert( t == a ); --- I have not expected assert(t == a) to be true - i would like to know the argument for why this is correct when at the same time assert(!a)

Re: Struct delegate access corruption

2021-02-17 Thread tsbockman via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 20:18:53 UTC, Paul Backus wrote: On Wednesday, 17 February 2021 at 19:42:00 UTC, tsbockman wrote: A copy constructor and opAssign can be used to update pointers that are relative to : https://dlang.org/spec/struct.html#struct-copy-constructor

Re: null and initialized string comparisons

2021-02-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 20:48:22 UTC, Martin wrote: is this how it supposed to be? (https://run.dlang.io/is/7B4irm) == compares contents. Both null and "" have empty contents and are interchangable for operators that work on contents. The assert just looks at the pointer, not

Wrapping C++ class with virtual destructor

2021-02-17 Thread Gregor Mückl via Digitalmars-d-learn
Hi! How do I wrap an existing C++ class with a virtual destructor in D? Take, for example, this C++ class: class Base { public: virtual ~Base(); virtual void foo() = 0; } What does the equivalent extern(C++) declaration in D look like? I don't care about calling the destructor. My

Re: Struct delegate access corruption

2021-02-17 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 19:42:00 UTC, tsbockman wrote: On Wednesday, 17 February 2021 at 17:45:01 UTC, H. S. Teoh wrote: I.e., the following is NOT a good idea: struct S { void delegate() member; this() { member =

Re: Struct delegate access corruption

2021-02-17 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Feb 17, 2021 at 03:38:00PM +, z via Digitalmars-d-learn wrote: > So i've upgraded one of my structs to use the more flexible delegates > instead of function pointers but when the member function tries to > access the struct's members, the contents are random and the program > fails.

Re: How to get output of piped process?

2021-02-17 Thread Jedi via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 14:36:58 UTC, Steven Schveighoffer wrote: On 2/17/21 1:58 AM, Jedi wrote: I an using pipeShell, I have redirected stdout, stderr, and stdin. I am trying to read from the output and display it in my app. I have followed this code almost exactly except I use

Re: Wrapping C++ class with virtual destructor

2021-02-17 Thread kinke via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 22:53:05 UTC, Gregor Mückl wrote: Hi! How do I wrap an existing C++ class with a virtual destructor in D? Take, for example, this C++ class: class Base { public: virtual ~Base(); virtual void foo() = 0; } What does the equivalent extern(C++)