Re: Removing elements from dynamic arrays?

2022-04-05 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 5 April 2022 at 14:10:44 UTC, Steven Schveighoffer wrote: [...] I'd implement it probably like this (for D2): ```d auto drop(T)(ref T[] arr, T which) { import std.algorithm, std.range; auto f = arr.find(which); debug if(f.empty) throw ...; auto result = arr.front; arr

Re: Removing elements from dynamic arrays?

2022-04-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/5/22 11:43 AM, Paul Backus wrote: On Tuesday, 5 April 2022 at 14:10:44 UTC, Steven Schveighoffer wrote: I'd implement it probably like this (for D2): ```d auto drop(T)(ref T[] arr, T which) {    import std.algorithm, std.range;    auto f = arr.find(which);    debug if(f.empty) throw ...;  

Re: Removing elements from dynamic arrays?

2022-04-05 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 5 April 2022 at 14:10:44 UTC, Steven Schveighoffer wrote: I'd implement it probably like this (for D2): ```d auto drop(T)(ref T[] arr, T which) { import std.algorithm, std.range; auto f = arr.find(which); debug if(f.empty) throw ...; auto result = arr.front; arr = arr.

Re: Removing elements from dynamic arrays?

2022-04-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/4/22 7:15 PM, Enjoys Math wrote: https://forum.dlang.org/post/eih04u$1463$1...@digitaldaemon.com A version of the code that takes `T which` as a parameter instead of `int index`. ``` // remove an item from an array template drop(T) {   T drop( inout T[] arr, T which ) Note to reader:

Re: Check if Key exists in Associative Array using D language.

2022-04-05 Thread BoQsc via Digitalmars-d-learn
On Tuesday, 5 April 2022 at 11:53:19 UTC, Dennis wrote: On Tuesday, 5 April 2022 at 11:26:27 UTC, BoQsc wrote: I'd like to know if there is similar function: that can check if a **key** inside a [Associative Array][2] can be found. You can use the `in` operator for that: https://dlang.org/spec

Re: Check if Key exists in Associative Array using D language.

2022-04-05 Thread Dennis via Digitalmars-d-learn
On Tuesday, 5 April 2022 at 11:26:27 UTC, BoQsc wrote: I'd like to know if there is similar function: that can check if a **key** inside a [Associative Array][2] can be found. You can use the `in` operator for that: https://dlang.org/spec/hash-map.html#testing_membership

Check if Key exists in Associative Array using D language.

2022-04-05 Thread BoQsc via Digitalmars-d-learn
I've found [std.algorithm: canFind][1] to be useful on a **regular arrays**. I'd like to know if there is similar function: that can check if a **key** inside a [Associative Array][2] can be found. [1]:https://dlang.org/phobos/std_algorithm_searching.html#.canFind [2]:https://dlang.org/spec/h

Re: How to use an existing D package in Visual D?

2022-04-05 Thread realhet via Digitalmars-d-learn
On Tuesday, 5 April 2022 at 09:57:29 UTC, Mike Parker wrote: On Tuesday, 5 April 2022 at 09:26:54 UTC, realhet wrote: You should compile the existing package as a library, then add the library file to the linker settings in VisualD. Thank You for the fast help! Currently I have my own build s

Re: How to use an existing D package in Visual D?

2022-04-05 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 5 April 2022 at 09:26:54 UTC, realhet wrote: Hello, I have all my D packages in the c:\D\libs\ directory. I added this path to the PropertyPages/Compiler/Additional Import Paths field. In the project source file I imported a module from my package using "import het.utils;" Also

How to use an existing D package in Visual D?

2022-04-05 Thread realhet via Digitalmars-d-learn
Hello, I have all my D packages in the c:\D\libs\ directory. I added this path to the PropertyPages/Compiler/Additional Import Paths field. In the project source file I imported a module from my package using "import het.utils;" Also used a function from it. The syntax highlighter worked go