Re: Manipulate slice or specific element of range and return range

2018-03-21 Thread Seb via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 11:30:28 UTC, Timoses wrote: Hey, I'm struggling to find a way to achieve this. I've looked through std.algorithm but didn't find anything.. Maybe I'm blind. What I would like to do is filter out all spaces in a string and change the front letter to lower

Re: Understanding slide

2018-03-21 Thread Seb via Digitalmars-d-learn
On Thursday, 22 March 2018 at 03:58:35 UTC, Seb wrote: On Thursday, 22 March 2018 at 03:39:38 UTC, Jordan Wilson wrote: auto a = iota(5).slide!(Yes.withPartial)(3); auto b = iota(5).slide!(No.withPartial)(3); assert (a.equal(b)); The assert passes, but I would expect it to fail? They both

Re: Understanding slide

2018-03-21 Thread Seb via Digitalmars-d-learn
On Thursday, 22 March 2018 at 03:39:38 UTC, Jordan Wilson wrote: auto a = iota(5).slide!(Yes.withPartial)(3); auto b = iota(5).slide!(No.withPartial)(3); assert (a.equal(b)); The assert passes, but I would expect it to fail? They both are: [[0,1,2],[1,2,3],[2,3,4]] Thanks, Jordan See:

Understanding slide

2018-03-21 Thread Jordan Wilson via Digitalmars-d-learn
auto a = iota(5).slide!(Yes.withPartial)(3); auto b = iota(5).slide!(No.withPartial)(3); assert (a.equal(b)); The assert passes, but I would expect it to fail? They both are: [[0,1,2],[1,2,3],[2,3,4]] Thanks, Jordan

Re: recursive template expansion: Why does this not compile?

2018-03-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 21, 2018 22:50:32 Ontonator via Digitalmars-d-learn wrote: > On Wednesday, 21 March 2018 at 06:39:22 UTC, ag0aep6g wrote: > > On 03/21/2018 01:47 AM, Ontonator wrote: > >> The following code does not compile: > >>> [...] > >> > >> It gives the error: > >>> [...] > >> > >> The

Re: D's type declarations seem to read right to left.

2018-03-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 21, 2018 20:07:09 tipdbmp via Digitalmars-d-learn wrote: > D's type declarations seem to read right to left. > > > int an_integer; > > int[10] an_array_of_10_integers; > int[10]* a_pointer_to_an_array_of_10_integers = > _array_of_10_integers; > > int*[10]

Re: recursive template expansion: Why does this not compile?

2018-03-21 Thread Ontonator via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 06:39:22 UTC, ag0aep6g wrote: On 03/21/2018 01:47 AM, Ontonator wrote: The following code does not compile: [...] It gives the error: [...] The aliases do not have to be aliases, as long as there is some reference to the class (e.g. method and variable

Re: Slow start up time of runtime (correction: Windows real-time protection)

2018-03-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 13:26:48 UTC, HeiHon wrote: In Windows Security Center Settings (where you can disable realtime scan) there is also an entry "Exclusions" (in german windows "Ausschlüsse"). I added exclusions for the folder, where I installed dmd and ldc and I added an exclusion

Re: Need example of usage DerelictPQ

2018-03-21 Thread number via Digitalmars-d-learn
On Wednesday, 24 December 2014 at 11:56:40 UTC, Suliman wrote: Could anybody provide any simple examples of usage DerelictPQ. I do not have experience of C, and I can't understand how to use this driver. I need just basics like connect, select and insert.

Re: Slow start up time of runtime (correction: Windows real-time protection)

2018-03-21 Thread Dennis via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 13:26:48 UTC, HeiHon wrote: I added exclusions for the folder, where I installed dmd and ldc and I added an exclusion for the folder, where I compile my D programs. Now startup of dmd and freshly compiled programs is fast again. I've done this too now, thanks

Re: OK, I'm stumped on this one: dstep, struct, mixin, bitfields

2018-03-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-03-21 20:30, Russel Winder wrote: Thanks to Adam and Ali, it was clear and obvious. Please report and issue so it's not forgotten. -- /Jacob Carlborg

Re: Packages and module import

2018-03-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-03-21 17:06, Russel Winder wrote: No I wasn't. And it works a treat. Cool :). I recommend having a look at the changelog and the usage information (--help). -- /Jacob Carlborg

Re: D's type declarations seem to read right to left.

2018-03-21 Thread Nick Sabalausky via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 20:07:09 UTC, tipdbmp wrote: D's type declarations seem to read right to left. int an_integer; int[10] an_array_of_10_integers; int[10]* a_pointer_to_an_array_of_10_integers = _array_of_10_integers; int*[10] an_array_of_10_pointers_to_integers; int*[10]*

Re: D's type declarations seem to read right to left.

2018-03-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 20:07:09 UTC, tipdbmp wrote: I think this is a big improvement over C's "spiral" way of reading types: Yes, D is perfect and has achieved sanity where before there was none. You can read basically anything with little knowledge. void function()[]

D's type declarations seem to read right to left.

2018-03-21 Thread tipdbmp via Digitalmars-d-learn
D's type declarations seem to read right to left. int an_integer; int[10] an_array_of_10_integers; int[10]* a_pointer_to_an_array_of_10_integers = _array_of_10_integers; int*[10] an_array_of_10_pointers_to_integers; int*[10]* a_pointer_to_an_array_of_10_pointers_to_integers =

Re: OK, I'm stumped on this one: dstep, struct, mixin, bitfields

2018-03-21 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 21, 2018 at 07:30:28PM +, Russel Winder via Digitalmars-d-learn wrote: [...] > But :-( > > Why does version have to be a keyword? [...] version(all) { ... } version(none) { ... } version(Posix) { ... } version(Windows) { ... } But yeah, using

Re: OK, I'm stumped on this one: dstep, struct, mixin, bitfields

2018-03-21 Thread Russel Winder via Digitalmars-d-learn
On Wed, 2018-03-21 at 18:11 +, Adam D. Ruppe via Digitalmars-d- learn wrote: > On Wednesday, 21 March 2018 at 18:00:38 UTC, Russel Winder wrote: > > ubyte, "version", 5, > > > version is a D keyword, so I would suggest trying "version_" > there instead and see if it works. (I'm

Re: strip() and formattedRead()

2018-03-21 Thread realhet via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 18:50:18 UTC, Adam D. Ruppe wrote: On Wednesday, 21 March 2018 at 18:44:12 UTC, realhet wrote: Compiling this I get an error: "formattedRead: cannot deduce arguments from (string, string, float, float, float)" What compiler version are you using? The newest

Re: why does this compile fine, but dies when you run it.

2018-03-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 18:53:39 UTC, steven kladitis wrote: int[] array3; array3[0]=4; array3 is empty. You are trying to set a value that doesn't exist..

Calling Windows Command

2018-03-21 Thread Vino via Digitalmars-d-learn
Hi All, Request your help in calling the windows command to delete all file and folders recursively as the D function rmdirRecurse does not delete file in the permission of the file is readonly in windows 2008 R2 import std.process: execute; import std.array: empty; auto RemoveDir () (

why does this compile fine, but dies when you run it.

2018-03-21 Thread steven kladitis via Digitalmars-d-learn
import std.stdio; void main(){ int[3] array1 = [ 10, 20, 30 ]; auto array2 = array1; // array2's elements are different // from array1's array2[0] = 11; int[] array3; //array4[0]=3; array3[0]=4; auto array4 = array3; writeln(array1,'\n',array2,'\n',array3,'\n',array4); } -- windows 7 64 bit (

Re: strip() and formattedRead()

2018-03-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 18:44:12 UTC, realhet wrote: Compiling this I get an error: "formattedRead: cannot deduce arguments from (string, string, float, float, float)" What compiler version are you using? The newest versions allow this code, though the old ones require an intermediate

Re: strip() and formattedRead()

2018-03-21 Thread Ali Çehreli via Digitalmars-d-learn
On 03/21/2018 11:44 AM, realhet wrote:   float x,y,z;   if(formattedRead("    vertex -5.1 2.4 3.666".strip, "vertex %f %f %f", x, y, z)){     writefln("v(%f, %f, %f)", x, y, z);   } formattedRead wants to modify the source, so it takes it by reference, which rvalues cannot be passed

Re: How to use an associative array with array values.

2018-03-21 Thread Jesse Phillips via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 18:31:29 UTC, tipdbmp wrote: I see. I guess the other would be: { int[8192] bar; int[8192][string] foo; foo["a"] = bar; foo["a"][8191] = -1; } https://run.dlang.io/is/AK2X2t Are you looking to use static arrays or dynamic? You can't use the new

strip() and formattedRead()

2018-03-21 Thread realhet via Digitalmars-d-learn
Hi, I just got this problem and since an hour can't find answer to it. float x,y,z; if(formattedRead("vertex -5.1 2.4 3.666".strip, "vertex %f %f %f", x, y, z)){ writefln("v(%f, %f, %f)", x, y, z); } Compiling this I get an error: "formattedRead: cannot deduce arguments from

Re: #import mapi.h

2018-03-21 Thread nkm1 via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 16:22:45 UTC, Martin Tschierschke wrote: Is there an step by step introduction how to convert a C header of an external lib into the right extern(C){} block? A blog post or tutorial, or chapter in a D book? (I have those from Packt Publishing) (Especially I am

Re: How to use an associative array with array values.

2018-03-21 Thread tipdbmp via Digitalmars-d-learn
I see. I guess the other would be: { int[8192] bar; int[8192][string] foo; foo["a"] = bar; foo["a"][8191] = -1; }

Re: Template condition evaluation (shortcircuit)

2018-03-21 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 21, 2018 at 05:42:34PM +, rumbu via Digitalmars-d-learn wrote: > I tried to define a template: > > enum isFoo(alias T) = > T.stringof.length >= 3 && T.stringof[0..3] == "abc"; > > int i; > pragma(msg, isFoo!i); > > Error: string slice [0 .. 3] is out of bounds > Error:

Re: OK, I'm stumped on this one: dstep, struct, mixin, bitfields

2018-03-21 Thread Ali Çehreli via Digitalmars-d-learn
On 03/21/2018 11:00 AM, Russel Winder wrote: > The code I am playing with generated by DStep involves lots of lots of > structs with mixin bitfields. All of them seem to compile file, except > one. How is it that: > > mixin(bitfields!( > ubyte, "current_next", 1, > ubyte,

Re: OK, I'm stumped on this one: dstep, struct, mixin, bitfields

2018-03-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 18:00:38 UTC, Russel Winder wrote: ubyte, "version", 5, version is a D keyword, so I would suggest trying "version_" there instead and see if it works. (I'm guessing btw, the error message was way to long and illegible, but this is an easy first guess

OK, I'm stumped on this one: dstep, struct, mixin, bitfields

2018-03-21 Thread Russel Winder via Digitalmars-d-learn
The code I am playing with generated by DStep involves lots of lots of structs with mixin bitfields. All of them seem to compile file, except one. How is it that: mixin(bitfields!( ubyte, "current_next", 1, ubyte, "version", 5, ubyte, "one2", 2)); /* TS ID */ can

Template condition evaluation (shortcircuit)

2018-03-21 Thread rumbu via Digitalmars-d-learn
I tried to define a template: enum isFoo(alias T) = T.stringof.length >= 3 && T.stringof[0..3] == "abc"; int i; pragma(msg, isFoo!i); Error: string slice [0 .. 3] is out of bounds Error: template object.__equals cannot deduce function from argument types !()(string, string), candidates

Re: #import mapi.h

2018-03-21 Thread Timoses via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 16:22:45 UTC, Martin Tschierschke wrote: Is there an step by step introduction how to convert a C header of an external lib into the right extern(C){} block? A blog post or tutorial, or chapter in a D book? (I have those from Packt Publishing) While googling I

Re: Manipulate slice or specific element of range and return range

2018-03-21 Thread Timoses via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 12:07:49 UTC, Simen Kjærås wrote: On Wednesday, 21 March 2018 at 11:30:28 UTC, Timoses wrote: unittest { assert("my capitalized string".capitalize == "myCapitalizedString"); } auto capitalize(string s) { import std.regex, std.uni; return

Re: Manipulate slice or specific element of range and return range

2018-03-21 Thread Timoses via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 12:53:56 UTC, Ali Çehreli wrote: Here is another one that uses ForwardRange. import std.range; // empty, take, save, chain, popFrontN; import std.uni; // asLowerCase; import std.algorithm; // equal, filter; import std.conv; // text; auto initialLowerCased(R)(R

Re: #import mapi.h

2018-03-21 Thread ketmar via Digitalmars-d-learn
Martin Tschierschke wrote: or tutorial ok, tutorial: 1. learn C. 2. learn D. 3. DO IT! ;-)

#import mapi.h

2018-03-21 Thread Martin Tschierschke via Digitalmars-d-learn
Is there an step by step introduction how to convert a C header of an external lib into the right extern(C){} block? A blog post or tutorial, or chapter in a D book? (I have those from Packt Publishing) (Especially I am trying to get this used with D: Montetdb C-API

Re: Incomprehensible error message

2018-03-21 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2018-03-20 at 14:18 -0700, H. S. Teoh via Digitalmars-d-learn wrote: > […] > > Either way, it will require a lot of effort to pull off. > As Rust has shown appreciating that the quality of the error messages define the quality of the compiler, the quality of the error message from rustc

Re: Packages and module import

2018-03-21 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2018-03-20 at 22:08 +0100, Jacob Carlborg via Digitalmars-d- learn wrote: > […] > Not sure if this will help, but are you aware that DStep can add a > package to the module declaration using "--package"? No I wasn't. And it works a treat. -- Russel.

Re: How to use an associative array with array values.

2018-03-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 15:53:32 UTC, tipdbmp wrote: int[10][string] foo; One option is to initialize like this --- void main() { int[10][string] foo; if("a" !in foo) foo["a"] = [0,0,0,0,0,0,0,0,0,0]; // set all to zero to create the key foo["a"][4] = 4; // now valid to

How to use an associative array with array values.

2018-03-21 Thread tipdbmp via Digitalmars-d-learn
// foo is an associative array/hashtable with // key type: string // value type: int[10] // int[10][string] foo; // foo["a"] = new int[10]; // Range violation at runtime // foo["a"][0] = 1; // Range violation at runtime

Issue with traits usability

2018-03-21 Thread Márcio Martins via Digitalmars-d-learn
Hi! How do I get past this? static struct X { int x; private enum T = 1; private alias M = string; } foreach (Member; __traits(allMembers, X)) { pragma(msg, __traits(getProtection, __traits(getMember, X, Member))); } Output: public private c.d(1084): Error:

How Does Language Interpretation Take Place In United Nations?

2018-03-21 Thread Globibo via Digitalmars-d-learn
You may be wondering whether the United Nations employ an interpreter for all dialects across the globe. It does not do so as the presenters at the UN should make their dose he's in any one of its 6 official languages, These official languages are Spanish, French, English, Chinese, Arabic, and

Re: Slow start up time of runtime (correction: Windows real-time protection)

2018-03-21 Thread HeiHon via Digitalmars-d-learn
On Tuesday, 20 March 2018 at 16:56:59 UTC, Dennis wrote: On Tuesday, 20 March 2018 at 12:18:16 UTC, Adam D. Ruppe wrote: On Tuesday, 20 March 2018 at 09:44:41 UTC, Dennis wrote: This now leaves the question what's the best way to mitigate this, because I would gladly get rid of the second of

Re: Manipulate slice or specific element of range and return range

2018-03-21 Thread Ali Çehreli via Digitalmars-d-learn
On 03/21/2018 04:30 AM, Timoses wrote: Hey, I'm struggling to find a way to achieve this. I've looked through std.algorithm but didn't find anything.. Maybe I'm blind. What I would like to do is filter out all spaces in a string and change the front letter to lower case:     string m =

Re: Static Arrays: Behaviour of Passing & Returning

2018-03-21 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 12:01:01 UTC, Quantum Nerd wrote: How is it possible that b in main() and r in the function occupy the same memory? I would expect the same behaviour as with c. Can somebody with more experience shed some light on this? I'm pretty sure you're seeing NRVO -

Re: Manipulate slice or specific element of range and return range

2018-03-21 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 11:30:28 UTC, Timoses wrote: Hey, I'm struggling to find a way to achieve this. I've looked through std.algorithm but didn't find anything.. Maybe I'm blind. What I would like to do is filter out all spaces in a string and change the front letter to lower

Static Arrays: Behaviour of Passing & Returning

2018-03-21 Thread Quantum Nerd via Digitalmars-d-learn
Hello everybody, I am fairly new to the D language, and I've been trying to understand the behaviour of passing arrays to functions, especially also static arrays. There is an example that puzzles me: import std.stdio; double[3] sqr( double[3] v ) { double[3] r; writefln( "v (%20s) : %s",

Manipulate slice or specific element of range and return range

2018-03-21 Thread Timoses via Digitalmars-d-learn
Hey, I'm struggling to find a way to achieve this. I've looked through std.algorithm but didn't find anything.. Maybe I'm blind. What I would like to do is filter out all spaces in a string and change the front letter to lower case: string m = "My Capital String"; string lower = m

Re: Is there a way to pipeline program with random-access ranges in C#?

2018-03-21 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 07:40:01 UTC, Dukc wrote: ...except that IEnumerables cannot popBack(), so can only do that by doing an additional copy and reversing that. But I quess there's no better alternative, short of doing it C-style... A random access range would be represented as

Re: Is there a way to pipeline program with random-access ranges in C#?

2018-03-21 Thread Dukc via Digitalmars-d-learn
On Tuesday, 20 March 2018 at 15:57:16 UTC, Kagamin wrote: On Tuesday, 20 March 2018 at 15:06:14 UTC, Dukc wrote: Won't quite do it, because that would not iterate backwards. Linq has no chunking, so you would need to write it, maybe similar to SelectMany, but with the opposite meaning.

Re: recursive template expansion: Why does this not compile?

2018-03-21 Thread ag0aep6g via Digitalmars-d-learn
On 03/21/2018 01:47 AM, Ontonator wrote: The following code does not compile: void main() {} class SuperClass {} class TemplatedClass(T : SuperClass) {} class A : SuperClass {     alias T = TemplatedClass!B; } class B : SuperClass {     alias T = TemplatedClass!C; } class C : SuperClass {}