Re: question on dub and postgresql
On Wed, Oct 07, 2020 at 07:15:42PM +, aberba via Digitalmars-d-learn wrote: [...] > It seems the D ecosystem is not immediately obvious to some people. > Dub, compilers, and IDEs are recurring issues. This is stuff that needs to be documented up-front and in-your-face. For example, if we're going to be serious about dub, all code examples on the front page of dlang.org ought to use it. Invocation syntax should be shown right there on the front page. It should permeate all documentation and frequently alluded to. Similarly, if we're serious about code.dlang.org, then it also needs to permeate all code examples on dlang.org throughout. It needs to be treated as first-class citizen. Otherwise, it can only be perceived as this nebulous side thing of unclear relevance that people will tend to ignore. T -- Computerese Irregular Verb Conjugation: I have preferences. You have biases. He/She has prejudices. -- Gene Wirchenko
Re: question on dub and postgresql
On Monday, 5 October 2020 at 09:05:16 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 08:54:39 UTC, Daniel Kozak wrote: On Mon, Oct 5, 2020 at 10:25 AM Alaindevos via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: [...] Yes and no. Dub is Dlang dependency solution but it is not installer as pip is [...] Yes if you want to use any of dub packages you need to add it as a dependency to your dub.json (dub.sdl) A name dependency solution is at least vage. How do I install , https://github.com/denizzzka/dpq2 on unix so in the code i write the .d files of that library and after compilation linked to the libary shared objects. For that shared object must be installed. How ? It seems the D ecosystem is not immediately obvious to some people. Dub, compilers, and IDEs are recurring issues.
Re: If and isType with arrays
On Wednesday, 7 October 2020 at 16:39:07 UTC, Paul Backus wrote: On Wednesday, 7 October 2020 at 16:25:33 UTC, DMon wrote: Can isType be used as a condition in an if statement with arrays? You can do this with `is()` and `typeof()`: if (is(typeof(a) == int[5])) { write("true"); } The example you have that "works" is just a coincidence: I had previously gotten your example to work along with other basic properties to enter the if statement and isType in the write function. Thanks for the clarification and the note on the second part.
Re: If and isType with arrays
On Wednesday, 7 October 2020 at 16:25:33 UTC, DMon wrote: Can isType be used as a condition in an if statement with arrays? import std.stdio; import std.traits; void main() { int[5] a = [1,2,3,4,5]; // Something like this: if (a == isType!(int[5])) { write("true"); } // This works: if (a[0] == isType!(int)) { write("true"); } } You can do this with `is()` and `typeof()`: if (is(typeof(a) == int[5])) { write("true"); } The example you have that "works" is just a coincidence: `isType!(int)` evaluates to the boolean value `true` (because `int` is, indeed, a type), which compares equal to the integer `1`.
If and isType with arrays
Can isType be used as a condition in an if statement with arrays? import std.stdio; import std.traits; void main() { int[5] a = [1,2,3,4,5]; // Something like this: if (a == isType!(int[5])) { write("true"); } // This works: if (a[0] == isType!(int)) { write("true"); } }
Wanted! Tree Node implementation.
Wanted! Tree Node implementation. Like a: mixin template TreeNode( T ) { T parent; T firstChild; T lastChild; T prevSibling; T nextSibling; // ForwardRange implementation @property T front() { ... } @property bool empty() { ... } void popFront() { ... } // BackwardRange implementation @property T back() { ... } void popBack(); // RandomAccessRange implementation T opIndex( ... ) { ... } // length implementation @property size_t length() { ... } } It would be nice to get a link or package or source...
Re: Efficient sort function allowing own test and swap function as parameter
On Tuesday, 6 October 2020 at 22:18:39 UTC, Alaindevos wrote: I have a large table consisting of two columns.One with words.Another with frequencies. I want to sort them efficiently according to the names or frequency. For this I need an efficient sort function where I can plugin my proper test of order, and proper swap. Currently I do it using an own written bubble sort that doesn't scale well. you can use std.range:zip with std.algorithm:sort: import std; void main() { string[] names = ["Bob", "Alice", "Foo", "Bar"]; int[] freq = [5, 7, 1, 6]; zip(names, freq).sort!"a[0] < b[0]"; // sort by name writeln(names); writeln(freq); zip(names, freq).sort!"a[1] < b[1]"; // sort by frequency writeln(names); writeln(freq); }
Re: Efficient sort function allowing own test and swap function as parameter
On Wednesday, 7 October 2020 at 00:08:06 UTC, Ali Çehreli wrote: On 10/6/20 3:18 PM, Alaindevos wrote: [...] I had fun writing the following program. Note how makeIndex allows visiting elements in sorted order without actually sorting them. [...] Nice use of iota!