return type based on content of an array

2018-02-20 Thread thorstein via Digitalmars-d-learn
Hi, I'm going circles... ;) I read a string that contains an array of unknown dimension like: a = [1,2,3,4] or a = [[1,2],[3,4]] or a = [[[1,2],[3,4]],[[5,6],[7,8]]] With that I want to perform specified operations e.g. also provided on command line. Because at compile time the dimension

Re: confused with data types

2018-02-18 Thread thorstein via Digitalmars-d-learn
Thanks for all the insights :)

Re: confused with data types

2018-02-18 Thread thorstein via Digitalmars-d-learn
On Sunday, 18 February 2018 at 12:51:04 UTC, thorstein wrote: Thank you for the very informative answers showing different gears in D! However, there are still some details I'm struggling with: Assume some calculations on a very big numeric array 'double[][][] arr'. Now we could choose 1

Re: confused with data types

2018-02-18 Thread thorstein via Digitalmars-d-learn
Thank you for the very informative answers showing different gears in D! However, there are still some details I'm struggling with: Assume some calculations on a very big numeric array 'double[][][] arr'. Now we could choose 1 out of 3 different implementations: // Solution 1 foreach(row;

confused with data types

2018-02-17 Thread thorstein via Digitalmars-d-learn
Hello, This was my goal: - public double[][] skalar_m_2d(double[][] array, double skalar) { return array.map!(b => b[].map!(c => c * skalar)); } !!! But: return value is not double! Type check for return value: a = array.map!(b => b[].map!(c => c

conversion error related to array index

2017-10-04 Thread thorstein via Digitalmars-d-learn
Hi, I get the following compile error with this function below: source\mod_data\matrices.d(66,12): Error: cannot implicitly convert expression (j) of type ulong to uint (66,12) is [j] in row[j] Using uint as type for rows, cols (i.e. the indices) works. Is ulong not allowed for array

Re: how to use unknown size of array at compile time for further processing

2017-10-01 Thread thorstein via Digitalmars-d-learn
Replace arrayT ~= rowT; with arrayT ~= rowT.dup; Also, you may want to look into ndslice package [1]. [1] https://github.com/libmir/mir-algorithm Best regards, Ilya Yaroshenko Works! Thanks Ilya. I'll take a look on the difference. Also soon will get bit familiar with the mir-algorithm...

Re: how to use unknown size of array at compile time for further processing

2017-10-01 Thread thorstein via Digitalmars-d-learn
Guyes, I obviously made a mistake. Forget my post! Sorry, I'm still really confused with the results from my function: double[][] transp(double[][] array) { double[][] arrayT; double[] rowT; // initialize rowT foreach(i; 0..array.length) { rowT ~= 0; } foreach(col;

Re: how to use unknown size of array at compile time for further processing

2017-10-01 Thread thorstein via Digitalmars-d-learn
On Sunday, 1 October 2017 at 13:53:57 UTC, thorstein wrote: Why is that Thanks! Guyes, I obviously made a mistake. Forget my post!

Re: how to use unknown size of array at compile time for further processing

2017-10-01 Thread thorstein via Digitalmars-d-learn
They are not alternatives. They are the only way of doing things. Yes, sounds logic - static arrays require a size before compilation. However, I tried another variation with a totally unexpected result: double[][] transp3(double[][] array) { double[][] arrayT; double[] rowT; //

how to use unknown size of array at compile time for further processing

2017-10-01 Thread thorstein via Digitalmars-d-learn
Hi, assumed, I need the size of a dynamic array for further processing, which is unknown at compile time. Below are my example, which doesn't work and two alternatives. Alternative1: may create large rowT-arrays depending on original array size. Alternative2: overrides rowT after exiting the

Re: questions about dub

2017-03-21 Thread thorstein via Digitalmars-d-learn
Ups, somehow overread the last sentence of tourge :) Thanks for the detailed insights!

Re: questions about dub

2017-03-21 Thread thorstein via Digitalmars-d-learn
Thanks to all, I got it! I created a new dub package and copied my code there. Compiles. So I guess I get the rest working as well. Still will have to figure out later the procedure to do the same for a VisualD project, if it is possible. Thorstein

questions about dub

2017-03-21 Thread thorstein via Digitalmars-d-learn
Hi, I have questions regarding the usage of 'dub'. I'm learning D under Win7. I have installed VisualD for the community edition of Visual Studio and got some file i/o working. Next I would like to continue with the mir-tools for matrix manipulation. I understood that I have to build them

Re: code D'ish enough? - ignore previous post with same subject

2017-02-27 Thread Thorstein via Digitalmars-d-learn
On Sunday, 26 February 2017 at 21:50:38 UTC, Jordan Wilson wrote: auto readNumMatCsv2 (string filePath, string ndv, string new_ndv){ double[][] p_numArray; try { auto lines = File(filePath,"r").byLine; lines.popFront; // get read of header p_numArray =

Re: code D'ish enough? - ignore previous post with same subject

2017-02-27 Thread Thorstein via Digitalmars-d-learn
I really appriciate your comments and thoughts! On Sunday, 26 February 2017 at 21:02:52 UTC, ag0aep6g wrote: On Sunday, 26 February 2017 at 19:34:33 UTC, thorstein wrote: * "no-data-value"? No-data-values in data sets are common at least in geosciences: raster images, spatial simulation

code D'ish enough? - ignore previous post with same subject

2017-02-26 Thread thorstein via Digitalmars-d-learn
Hi, sorry for posting again, but I used a keyboard combination that accidently send my post before it was done. Coming more or less from Python I just started with D. Not a real programmer, just automating things and looking for a neat compiled language. Just to learn, I wrote a function

code D'ish enough?

2017-02-26 Thread thorstein via Digitalmars-d-learn
Hi, coming more or less from Python I just started with D. Not a real programmer, just automating things and looking for a neat compiled language. Just to learn, I wrote a function to read CSV-like files (I know D has its own routine). Since I'm still a bit overwhelmed by the many complex