I thought we could leave off ()

2019-10-17 Thread Brett via Digitalmars-d-learn
auto n = (){ return Z[0]; }; n().X = X; I'm trying to alias nodes away but alias n = Z[0]; fails. Dropping () from n().X fails also.

Re: Does Visual D actually work?

2019-10-07 Thread Brett via Digitalmars-d-learn
On Monday, 7 October 2019 at 15:02:36 UTC, Just Dave wrote: I downloaded it after experiencing debugging issues with CodeBlocks (it wouldn't attach the provided debugger). I downloaded Visual D and after some fiddling with Visual Studio 2019 not supporting third party templates in my version

Re: Ranges to deal with corner cases and "random access"

2019-10-06 Thread Brett via Digitalmars-d-learn
Here is a sort of proof of concept: struct CtsExtend { static auto opCall(T)(T a) { struct _CtsExtend { T _a; auto opIndex(int i) { if (i < 0)

Ranges to deal with corner cases and "random access"

2019-10-04 Thread Brett via Digitalmars-d-learn
Typically a lot of algorithms have corner cases such as referencing elements that end up out of bounds at the start or end (k-c or k+c). Is there any way to handle such things easily without having to worry about the corners? E.g., have it return a default value such as 0, or repeat the

Re: using regex at compile time errors out! Error: static variable `thompsonFactory` cannot be read at compile time

2019-10-04 Thread Brett via Digitalmars-d-learn
On Friday, 4 October 2019 at 10:07:40 UTC, kinke wrote: Have you tried ctRegex? Yes, just another error about something else that I don't remember.

Simple way to dereference common symbol

2019-10-04 Thread Brett via Digitalmars-d-learn
I have some algorithmic code that uses the same dereferencing symbol quite often, like .X It's used in ranges, in predicates, in strings, etc and other things but is used a lot. The object it acts on has several fields and I would like to use them. is there a way to use a abstract this

using regex at compile time errors out! Error: static variable `thompsonFactory` cannot be read at compile time

2019-10-03 Thread Brett via Digitalmars-d-learn
auto r = replaceAll!((C) { return "X"; } )(s, regex(`Y`)); Error: static variable `thompsonFactory` cannot be read at compile time This is

Re: Saving and loading large data sets easily and efficiently

2019-10-03 Thread Brett via Digitalmars-d-learn
On Thursday, 3 October 2019 at 14:38:35 UTC, Bastiaan Veelo wrote: On Monday, 30 September 2019 at 20:10:21 UTC, Brett wrote: [...] The way the data is structured is that I have a master array of non-ptr structs. E.g., S[] Data; S*[] OtherStuff; then every pointer points to an element in to

Using algorithms with ranges

2019-10-02 Thread Brett via Digitalmars-d-learn
I routinely have to generate data using points sequentially and refer to previous points in the data set, maybe even search them. I also may have to break up the algorithm in to parts. I'd like to get more in to ranges but I simply do not use them much because I don't know all the fancy stuff

Re: Struct initialization has no effect or error?

2019-10-02 Thread Brett via Digitalmars-d-learn
On Wednesday, 2 October 2019 at 17:54:20 UTC, H. S. Teoh wrote: On Wed, Oct 02, 2019 at 05:37:57PM +, Brett via Digitalmars-d-learn wrote: struct X { int a; } X[1] x; x[0] = {3}; or x[0] = {a:3}; fails; This works: x[0] = X(123); Should the syntax not extend to the case

Why is it difficult to reference arrays in structs?

2019-10-02 Thread Brett via Digitalmars-d-learn
struct Y { double q; } struct X { Y[] a; } X x; auto r = x.a; r is not a reference?!?! When updating x.a, r is not updated ;/ [I'm not sure if it just creates a slice or what] Ok, fine! auto r = Now r is a reference, great!. But now the semantics of using the array completely change

Struct initialization has no effect or error?

2019-10-02 Thread Brett via Digitalmars-d-learn
struct X { int a; } X[1] x; x[0] = {3}; or x[0] = {a:3}; fails; Should the syntax not extend to the case of array assignment? This avoids a double copy. X y = {3}; works fine. So one has to do x[0] = y;

Saving and loading large data sets easily and efficiently

2019-09-30 Thread Brett via Digitalmars-d-learn
I have done some large computations where the data set is around 10GB and takes several minutes to run. Rather than running it every time regenerating the same data, can I simply save it to disk easily? The data is ordered in arrays and structs. It's just numbers/POD except some arrays use

Re: wstring comparison is failing

2019-09-24 Thread Brett via Digitalmars-d-learn
On Tuesday, 24 September 2019 at 00:29:05 UTC, Vladimir Panteleev wrote: On Monday, 23 September 2019 at 23:22:14 UTC, Brett wrote: I guess you are probably right... I was thinking that it would compare up to a null terminator. Seems kinda buggy... maybe the compiler needs to give a warning?

Re: wstring comparison is failing

2019-09-23 Thread Brett via Digitalmars-d-learn
On Monday, 23 September 2019 at 20:45:00 UTC, destructionator wrote: On Mon, Sep 23, 2019 at 08:38:03PM +, Brett via Digitalmars-d-learn wrote: The only thing is that szExeFile is a static wchar array... which shouldn't effect the comparison. are you sure about that? with a static size

wstring comparison is failing

2019-09-23 Thread Brett via Digitalmars-d-learn
cast(wstring)entry.szExeFile == Name to!wstring(entry.szExeFile) == Name These all fail. The strings are clearly the same. I can compare char by char and it works. latest D 2.088. The only thing is that szExeFile is a static wchar array... which shouldn't effect the comparison.

Single D app entered multiple times from command line

2019-09-23 Thread Brett via Digitalmars-d-learn
Is there a way too have a single D process run and be called multiple times from the command line without too much work? Basically any time the process is called by the command line it will "enter" only one process... and if that process is being debugged the entries can be debugged too.

Re: Collect Statistics efficiently and easily

2019-09-18 Thread Brett via Digitalmars-d-learn
On Tuesday, 17 September 2019 at 14:06:41 UTC, Paul Backus wrote: On Tuesday, 17 September 2019 at 01:53:39 UTC, Brett wrote: Many times I have to get statistical info which is simply compute statistics on a data set that may be generating or already generated. The code usually is M =

Re: Dynamic array + AA array

2019-09-17 Thread Brett via Digitalmars-d-learn
On Tuesday, 17 September 2019 at 15:51:34 UTC, Andrea Fontana wrote: On Tuesday, 17 September 2019 at 14:33:30 UTC, Brett wrote: The idea is to basically use a dynamic array for most of the items, then an array to get the rest. T[] Base; T[int] Rest; Then if Base has a max size(usually it

Re: matplotlibD returns

2019-09-17 Thread Brett via Digitalmars-d-learn
On Tuesday, 17 September 2019 at 15:21:37 UTC, jmh530 wrote: On Tuesday, 17 September 2019 at 01:54:01 UTC, Brett wrote: How does one get return values? https://matplotlib.org/3.1.0/gallery/statistics/hist.html Shows that python uses return values to set properties of the plot

Dynamic array + AA array

2019-09-17 Thread Brett via Digitalmars-d-learn
The idea is to basically use a dynamic array for most of the items, then an array to get the rest. T[] Base; T[int] Rest; Then if Base has a max size(usually it might be fixed due to some algorithm) the Rest AA can pick up any outside values easily. The idea here is to be able to combine

Collect Statistics efficiently and easily

2019-09-16 Thread Brett via Digitalmars-d-learn
Many times I have to get statistical info which is simply compute statistics on a data set that may be generating or already generated. The code usually is M = max(M, v); m = min(m, v); but other things like standard deviation, mean, etc might need to be computed. This may need to be done

matplotlibD returns

2019-09-16 Thread Brett via Digitalmars-d-learn
How does one get return values? https://matplotlib.org/3.1.0/gallery/statistics/hist.html Shows that python uses return values to set properties of the plot https://github.com/koji-kojiro/matplotlib-d/blob/master/examples/source/app.d Does not give any examples of return values and when

Chains

2019-09-16 Thread Brett via Digitalmars-d-learn
Anyone have a better way to accomplish the following task: An algorithm computes various values for a graph structure. The graph contains many loops and nested loops. Each node has a chain associated with it, which is how it is connected to the rest of the graph. The problem is to save

Re: Slicing upward

2019-09-14 Thread Brett via Digitalmars-d-learn
On Saturday, 14 September 2019 at 11:39:21 UTC, rikki cattermole wrote: On 14/09/2019 11:34 PM, Brett wrote: I have an algorithm that is most efficiently implement by taking an array and slicing it upward, meaning removing the leading elements. Because the algorithm is complex(deterministic

Slicing upward

2019-09-14 Thread Brett via Digitalmars-d-learn
I have an algorithm that is most efficiently implement by taking an array and slicing it upward, meaning removing the leading elements. Because the algorithm is complex(deterministic but chaotic) and deals with multiple arrays it is difficult to efficiently use slicing. Is there some easy