Re: Measuring test coverage

2015-08-09 Thread Rikki Cattermole via Digitalmars-d-learn
On 10/08/2015 8:24 a.m., Alexei Bykov wrote: D has builtin support for coverage analysis but it produces only .lst files. This is a bit inconvenient. Is there any tool which can create something like an html report from .lst files? For now I'm using OpenCppCoverage which is not the best tool and

Re: Concurrency Confusion

2015-08-09 Thread 岩倉 澪
On Sunday, 9 August 2015 at 21:06:10 UTC, anonymous wrote: On Sunday, 9 August 2015 at 17:43:59 UTC, 岩倉 澪 wrote: Afaict it is the best way to do what I'm trying to do, and since the data is mutable and cast to immutable with assumeUnique, casting it back to mutable shouldn't be a problem. Tech

Re: Removing elements from dynamic array

2015-08-09 Thread Reflexive via Digitalmars-d-learn
On Sunday, 9 August 2015 at 20:38:05 UTC, drug wrote: 09.08.2015 23:22, Reflexive пишет: Try to use this.sabotarray = this.sabotarray.remove(id_card); remove() removes element(s) but doesn't change length of 'old' array. To get new length you should use 'new' array that returned from remove

Re: Concurrency Confusion

2015-08-09 Thread anonymous via Digitalmars-d-learn
On Sunday, 9 August 2015 at 17:43:59 UTC, 岩倉 澪 wrote: Afaict it is the best way to do what I'm trying to do, and since the data is mutable and cast to immutable with assumeUnique, casting it back to mutable shouldn't be a problem. Technically casting away immutable might be undefined behaviour

Re: Dynamic array and foreach loop

2015-08-09 Thread Jay Norwood via Digitalmars-d-learn
On Sunday, 9 August 2015 at 19:10:01 UTC, Binarydepth wrote: On Sunday, 9 August 2015 at 16:42:16 UTC, Jay Norwood wrote: Oooh... I like how this works import std.stdio : writeln, readf; void main() { immutable a=5; int[a] Arr; int nim; foreach(num, ref nem; A

Re: std.array: array, ulong and Win32

2015-08-09 Thread ixid via Digitalmars-d-learn
On Sunday, 9 August 2015 at 20:33:10 UTC, anonymous wrote: On Sunday, 9 August 2015 at 20:13:38 UTC, ixid wrote: Yup, bug. Please file an issue at . It seems like bearophile beat me to it. Good to see he's still alive. https://issues.dlang.org/show_bug.cgi?id=148

Re: Removing elements from dynamic array

2015-08-09 Thread drug via Digitalmars-d-learn
09.08.2015 23:22, Reflexive пишет: Try to use this.sabotarray = this.sabotarray.remove(id_card); remove() removes element(s) but doesn't change length of 'old' array. To get new length you should use 'new' array that returned from remove(). In this case I get rid of two excessive kings in ca

Re: Removing elements from dynamic array

2015-08-09 Thread anonymous via Digitalmars-d-learn
On Sunday, 9 August 2015 at 20:23:00 UTC, Reflexive wrote: I see that remove() removes the value of the element but keeps the same size of the array, and replace the value by a new one at the end. The method : class sabot{ card[] sabotarray ; (...) card getCard(){

Re: std.array: array, ulong and Win32

2015-08-09 Thread Timon Gehr via Digitalmars-d-learn
On 08/09/2015 10:13 PM, ixid wrote: This seems like a reasonable use but errors, obviously I can do it in many other ways: ulong[] result = iota(1UL, 10UL).array; Error: static assert "Argument types in (ulong) are not all convertible to size_t: (ulong)"C:\D\dmd2\src\phobos\std\array

Re: std.array: array, ulong and Win32

2015-08-09 Thread anonymous via Digitalmars-d-learn
On Sunday, 9 August 2015 at 20:13:38 UTC, ixid wrote: This seems like a reasonable use but errors, obviously I can do it in many other ways: ulong[] result = iota(1UL, 10UL).array; Error: static assert "Argument types in (ulong) are not all convertible to size_t: (ulong)" C:\D\dmd2\src

Measuring test coverage

2015-08-09 Thread Alexei Bykov via Digitalmars-d-learn
D has builtin support for coverage analysis but it produces only .lst files. This is a bit inconvenient. Is there any tool which can create something like an html report from .lst files? For now I'm using OpenCppCoverage which is not the best tool and works only on Windows but at least it produc

Re: Removing elements from dynamic array

2015-08-09 Thread Reflexive via Digitalmars-d-learn
On Sunday, 9 August 2015 at 15:41:33 UTC, Alex Parrill wrote: Why not just use std.random.shuffle [1]? Well, I didn't knew about it, that's the reason ... For the shuffle method, it is certainly the best to do, but I need the remove() method at other places. I see that remove() removes the

std.array: array, ulong and Win32

2015-08-09 Thread ixid via Digitalmars-d-learn
This seems like a reasonable use but errors, obviously I can do it in many other ways: ulong[] result = iota(1UL, 10UL).array; Error: static assert "Argument types in (ulong) are not all convertible to size_t: (ulong)" C:\D\dmd2\src\phobos\std\array.d 516 And while I'm here why do ar

Re: Dynamic array and foreach loop

2015-08-09 Thread Binarydepth via Digitalmars-d-learn
On Sunday, 9 August 2015 at 16:42:16 UTC, Jay Norwood wrote: The i+3 initialization is just so you can see that v is the Arr member (not the index) in the other loops. import std.stdio : writeln; void main() { immutable a=5; int[a] Arr; foreach(i, ref v; Arr) {

Re: Concurrency Confusion

2015-08-09 Thread 岩倉 澪
On Saturday, 8 August 2015 at 05:14:20 UTC, Meta wrote: I'm not completely sure that it's bad in this case, but you really shouldn't be casting away immutable. It's undefined behaviour in D. Afaict it is the best way to do what I'm trying to do, and since the data is mutable and cast to immut

Re: Specify variable type for range of associative arrays.

2015-08-09 Thread Christopher Davies via Digitalmars-d-learn
On Sunday, 9 August 2015 at 14:35:23 UTC, Marc Schütz wrote: You can use InputRange: http://dlang.org/phobos/std_range_interfaces.html#InputRange e.g. auto input = yourOriginalData.map!someTransformation; InputRange!string range; if(where != "") range = inputRangeObject(inpu

Re: Concurrency Confusion

2015-08-09 Thread 岩倉 澪
On Saturday, 8 August 2015 at 06:24:30 UTC, sigod wrote: Use negative value for `receiveTimeout`. http://stackoverflow.com/q/31616339/944911 On Saturday, 8 August 2015 at 13:34:24 UTC, Chris wrote: Note aside: if you only import what you need (say `import std.concurrency : receiveTimeout; std.

Re: Dynamic array and foreach loop

2015-08-09 Thread Jay Norwood via Digitalmars-d-learn
On Sunday, 9 August 2015 at 15:37:23 UTC, Binarydepth wrote: So I should use the REF like this ? import std.stdio : writeln; void main() { immutable a=5; int[a] Arr; foreach(num; 0..a) { Arr[num] = num; } foreach(num, ref ele; Arr)

Re: file rawRead and rawWrite in chunks example

2015-08-09 Thread Jay Norwood via Digitalmars-d-learn
On Sunday, 9 August 2015 at 10:40:06 UTC, Nordlöw wrote: On Sunday, 9 August 2015 at 00:50:16 UTC, Ali Çehreli wrote: Ali Now benchmarks write and read separately: I benchmarked my first results: D:\visd\raw\raw\Release>raw time write msecs:457 time read msecs:75 This is for 160MB of data

Re: Dynamic array and foreach loop

2015-08-09 Thread Alex Parrill via Digitalmars-d-learn
On Sunday, 9 August 2015 at 15:37:23 UTC, Binarydepth wrote: So I should use the REF like this ? import std.stdio : writeln; void main() { immutable a=5; int[a] Arr; foreach(num; 0..a) { Arr[num] = num; } foreach(num, ref ele; Arr

Re: Removing elements from dynamic array

2015-08-09 Thread Alex Parrill via Digitalmars-d-learn
On Sunday, 9 August 2015 at 15:30:32 UTC, Reflexive wrote: I wrote import std.algorithm.remove ;, and I dont have any longer any error. But, it dont want to remove the item. Here is the source, the problem is in the shuffle() method : ... Why not just use std.random.shuffle [1]? import

Re: Dynamic array and foreach loop

2015-08-09 Thread Binarydepth via Digitalmars-d-learn
On Sunday, 9 August 2015 at 00:22:53 UTC, Jay Norwood wrote: On Saturday, 8 August 2015 at 18:28:25 UTC, Binarydepth wrote: This is the new code : foreach(num; 0..liEle) {//Data input loop write("Input the element : ", num+1, " "); readf(" %d", &liaOrig

Re: Removing elements from dynamic array

2015-08-09 Thread Reflexive via Digitalmars-d-learn
I wrote import std.algorithm.remove ;, and I dont have any longer any error. But, it dont want to remove the item. Here is the source, the problem is in the shuffle() method : // sabot.d // version 0.0.1 import std.stdio ; import std.random ; import std.algorithm : remove ; void main(){

Re: Specify variable type for range of associative arrays.

2015-08-09 Thread via Digitalmars-d-learn
On Sunday, 9 August 2015 at 14:23:33 UTC, Chris Davies wrote: The problem is, based on user input, I am optionally filtering a list, possibly passing it through 0, 1, 2 or more filters based on their input. Each successive filter runs on either the original range or the result of the previous f

Re: file rawRead and rawWrite in chunks example

2015-08-09 Thread Jay Norwood via Digitalmars-d-learn
On Sunday, 9 August 2015 at 11:06:34 UTC, Nordlöw wrote: On Sunday, 9 August 2015 at 10:40:06 UTC, Nordlöw wrote: Couldn't the chunk logic be deduced aswell? Yes :) See update at: https://github.com/nordlow/justd/blob/a633b52876388921ec49c189f374746f7b4d8c93/tests/t_rawio.d What would a su

Re: Removing elements from dynamic array

2015-08-09 Thread kinke via Digitalmars-d-learn
On Sunday, 9 August 2015 at 14:24:38 UTC, Reflexive wrote: Error: module remove is in file 'std/algorithm/remove.d' which cannot be read remove() is a function in module std.algorithm: import std.algorithm: remove; remove(foo);

Re: Removing elements from dynamic array

2015-08-09 Thread Rikki Cattermole via Digitalmars-d-learn
On 10/08/2015 2:24 a.m., Reflexive wrote: On Sunday, 9 August 2015 at 13:40:51 UTC, cym13 wrote: On Sunday, 9 August 2015 at 13:22:02 UTC, Reflexive wrote: You can use std.algorithm.remove for that. If you need more advanced ways to remove elements, you may want to switch from a regular dynamic

Re: Specify variable type for range of associative arrays.

2015-08-09 Thread Chris Davies via Digitalmars-d-learn
On Sunday, 9 August 2015 at 12:54:39 UTC, Nicholas Wilson wrote: On Sunday, 9 August 2015 at 01:29:16 UTC, Christopher Davies wrote: [...] using UFCS (universal function call syntax) you would normally write that as: records =records.filter!(r => r[where] == val)(); and then leveraging D's opt

Re: Removing elements from dynamic array

2015-08-09 Thread Reflexive via Digitalmars-d-learn
On Sunday, 9 August 2015 at 13:40:51 UTC, cym13 wrote: On Sunday, 9 August 2015 at 13:22:02 UTC, Reflexive wrote: You can use std.algorithm.remove for that. If you need more advanced ways to remove elements, you may want to switch from a regular dynamic array to a std.container.array. I get

Re: Removing elements from dynamic array

2015-08-09 Thread cym13 via Digitalmars-d-learn
On Sunday, 9 August 2015 at 13:22:02 UTC, Reflexive wrote: Hi I have seen that it is possible to remove an element from a associative array, but dont find any reference, including in D's specification, about any element removing in dynamic array. I can use loops for that, but isnt any way to

Removing elements from dynamic array

2015-08-09 Thread Reflexive via Digitalmars-d-learn
Hi I have seen that it is possible to remove an element from a associative array, but dont find any reference, including in D's specification, about any element removing in dynamic array. I can use loops for that, but isnt any way to simple reduce a dynamic array size ? Thank you

Re: Specify variable type for range of associative arrays.

2015-08-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 9 August 2015 at 01:29:16 UTC, Christopher Davies wrote: I'm just learning D. Something I often do in C# is have an IEnumerable (Range) of some type that is then conditionally filtered. It looks like this: IEnumerable> foo = bar; if (baz) { foo = foo.Where(d => d["key"] == valu

Re: file rawRead and rawWrite in chunks example

2015-08-09 Thread Nordlöw
On Sunday, 9 August 2015 at 10:40:06 UTC, Nordlöw wrote: Couldn't the chunk logic be deduced aswell? Yes :) See update at: https://github.com/nordlow/justd/blob/a633b52876388921ec49c189f374746f7b4d8c93/tests/t_rawio.d What would a suitable value for `preferred_disk_write_size` be? Is ther

Re: file rawRead and rawWrite in chunks example

2015-08-09 Thread Nordlöw
On Sunday, 9 August 2015 at 00:50:16 UTC, Ali Çehreli wrote: Ali Now benchmarks write and read separately: https://github.com/nordlow/justd/blob/0d746b2c1800a82a61a6cb7edcabfd9664066b2c/tests/t_rawio.d Couldn't the chunk logic be deduced aswell? Something like: void rawWriteInAutoChunks(R)(F