Re: std.array.array for immutable data types

2018-02-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 19 February 2018 at 07:08:49 UTC, Fra Mecca wrote: Is there a way to avoid using to! conversion here? immutable string[] dst = to!(immutable string[])(array(pipe.readEnd.byLineCopy)); assumeUnique. immutable string[] dst = pipe.readEnd.byLineCopy.array.assumeUnique;

Re: std.array.array for immutable data types

2018-02-18 Thread Seb via Digitalmars-d-learn
On Monday, 19 February 2018 at 07:08:49 UTC, Fra Mecca wrote: Is there a way to avoid using to! conversion here? immutable string[] dst = to!(immutable string[])(array(pipe.readEnd.byLineCopy)); Are you looking for something like assumeUnique [1]? ``` pipe.readEnd.byLineCopy.array.assumeUniq

std.array.array for immutable data types

2018-02-18 Thread Fra Mecca via Digitalmars-d-learn
Is there a way to avoid using to! conversion here? immutable string[] dst = to!(immutable string[])(array(pipe.readEnd.byLineCopy));

Re: multithread/concurrency/parallel methods and performance

2018-02-18 Thread Dmitry Olshansky via Digitalmars-d-learn
On Sunday, 18 February 2018 at 17:54:58 UTC, SrMordred wrote: I´m experimenting with threads and related recently. (i´m just started so may be some terrrible mistakes here) With this base work: foreach(i ; 0 .. SIZE) { results[i] = values1[i] * values2[i]; } and then with this 3 others met

Re: multithread/concurrency/parallel methods and performance

2018-02-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 18 February 2018 at 17:54:58 UTC, SrMordred wrote: I´m experimenting with threads and related recently. (i´m just started so may be some terrrible mistakes here) With this base work: foreach(i ; 0 .. SIZE) { results[i] = values1[i] * values2[i]; } and then with this 3 others met

Re: countUntil to print all the index of a given string.

2018-02-18 Thread psychoticRabbit via Digitalmars-d-learn
On Sunday, 18 February 2018 at 15:23:14 UTC, Cym13 wrote: On Sunday, 18 February 2018 at 14:48:59 UTC, Cym13 wrote: [...] Just thought of a much better/simpler solution for that last case that also doesn't force you to read all data (which might be impossible when dealing with infinite range

Re: Trying to forward unwrapped opDispatch names to alias this

2018-02-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 19 February 2018 at 00:42:05 UTC, aliak wrote: struct B(T) { T t; A a; alias a this; auto opDispatch(string name)() if (hasMember!(T, name)) { return mixin("t." ~ name); Did you perhaps mean `A` instead of `T` here? cuz in your code T is int, not the struct.

Trying to forward unwrapped opDispatch names to alias this

2018-02-18 Thread aliak via Digitalmars-d-learn
I have a scenario where I'm wrapping functionality for a type, but only if the contained type has a member. I want those to take precedence. If the member is not there, then I want to delegate to an aliases type via alias this. I get an error here when I call b.p. Even though property p is in

Re: isFuture

2018-02-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, February 18, 2018 19:10:02 Tofu Ninja via Digitalmars-d-learn wrote: > What is __traits(isFuture)? The language documents says it tests > for @future which doesn't really help as @future is undocumented. https://github.com/dlang/DIPs/blob/master/DIPs/DIP1007.md - Jonathan M Davis

isFuture

2018-02-18 Thread Tofu Ninja via Digitalmars-d-learn
What is __traits(isFuture)? The language documents says it tests for @future which doesn't really help as @future is undocumented.

Re: multithread/concurrency/parallel methods and performance

2018-02-18 Thread Jordan Wilson via Digitalmars-d-learn
On Sunday, 18 February 2018 at 17:54:58 UTC, SrMordred wrote: I´m experimenting with threads and related recently. (i´m just started so may be some terrrible mistakes here) With this base work: foreach(i ; 0 .. SIZE) { results[i] = values1[i] * values2[i]; } and then with this 3 others met

multithread/concurrency/parallel methods and performance

2018-02-18 Thread SrMordred via Digitalmars-d-learn
I´m experimenting with threads and related recently. (i´m just started so may be some terrrible mistakes here) With this base work: foreach(i ; 0 .. SIZE) { results[i] = values1[i] * values2[i]; } and then with this 3 others methods: parallel, spawn and Threads. this was my results: _base

Re: confused with data types

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

Re: countUntil to print all the index of a given string.

2018-02-18 Thread Cym13 via Digitalmars-d-learn
On Sunday, 18 February 2018 at 14:48:59 UTC, Cym13 wrote: [...] Just thought of a much better/simpler solution for that last case that also doesn't force you to read all data (which might be impossible when dealing with infinite ranges): import std.range; import std.algorithm;

Re: std.traits.isBoolean

2018-02-18 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 18 February 2018 at 14:52:37 UTC, Tony wrote: At https://dlang.org/library/std/traits/is_boolean.html it has: enum isBoolean(T) = is(BooleanTypeOf!T) && !isAggregateType!T; per: https://dlang.org/library/std/traits/is_aggregate_type.html isAggregateType is true for [struct, union,

std.traits.isBoolean

2018-02-18 Thread Tony via Digitalmars-d-learn
At https://dlang.org/library/std/traits/is_boolean.html it has: enum isBoolean(T) = is(BooleanTypeOf!T) && !isAggregateType!T; per: https://dlang.org/library/std/traits/is_aggregate_type.html isAggregateType is true for [struct, union, class, interface]. So BooleanTypeOf!T is true for struct

Re: confused with data types

2018-02-18 Thread arturg via Digitalmars-d-learn
On Sunday, 18 February 2018 at 13:08:09 UTC, thorstein wrote: On Sunday, 18 February 2018 at 12:51:04 UTC, thorstein wrote: // Solution 1 foreach(row; arr) { foreach(col; row) { col[] *= skalar; } } return arr; // Solution 2 import std.array; return array(arr.map!(b => array(b[].map!(c =>

Re: countUntil to print all the index of a given string.

2018-02-18 Thread Cym13 via Digitalmars-d-learn
On Sunday, 18 February 2018 at 11:55:37 UTC, Vino wrote: Hi All, Request your help on printing the all index of an array element , eg; the below code prints the index of the string "Test2" as [1], but the string "Test2" is present 2 times at index 1 and 4, so how do I print all the index

Re: Return value in BetterC mode.

2018-02-18 Thread meppl via Digitalmars-d-learn
On Saturday, 17 February 2018 at 13:47:28 UTC, meppl wrote: On Saturday, 17 February 2018 at 07:58:40 UTC, ANtlord wrote: ... ... sadly I have no good idea how to name the title of that issue :/ I looked at it again and came up with a title name: https://issues.dlang.org/show_bug.cgi?id=184

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 out

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; arr

countUntil to print all the index of a given string.

2018-02-18 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on printing the all index of an array element , eg; the below code prints the index of the string "Test2" as [1], but the string "Test2" is present 2 times at index 1 and 4, so how do I print all the index of a given string. import std.stdio; import std.containe