Re: Blog Post #0096: Hardware III - Keyboard and Mouse

2019-12-31 Thread bauss via Digitalmars-d-learn
On Tuesday, 31 December 2019 at 09:27:44 UTC, Ron Tarrant wrote: This week's post wraps up the year by looking at how to access keyboard and mouse events through the hardware Seat. You'll find it here: https://gtkdcoding.com/2019/12/31/0096-hardware-iii-keyboard-pointer.html Have a happy New

Re: Finding position of a value in an array

2019-12-31 Thread Daren Scot Wilson via Digitalmars-d-learn
On Tuesday, 31 December 2019 at 06:01:36 UTC, Paul Backus wrote: countUntil operates on ranges, and static arrays aren't ranges. To get a range from a static array, you have to slice it with the `[]` operator: int i = info.doos[].countUntil(important_d); (Why can't static arrays be

Re: What type does byGrapheme() return?

2019-12-31 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 31, 2019 at 04:36:56PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: > On 12/31/19 4:22 PM, H. S. Teoh wrote: [...] > > import std; > > void main() { > > auto x = "Bla\u0301hbla\u0310h\u0309!"; > > auto r = x.byGrapheme; > >

Re: What type does byGrapheme() return?

2019-12-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/31/19 4:22 PM, H. S. Teoh wrote: On Tue, Dec 31, 2019 at 04:02:47PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: On 12/31/19 2:58 PM, H. S. Teoh wrote: On Tue, Dec 31, 2019 at 09:33:14AM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: e.g.: writeln(" Text =

Re: What type does byGrapheme() return?

2019-12-31 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 31, 2019 at 04:02:47PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: > On 12/31/19 2:58 PM, H. S. Teoh wrote: > > On Tue, Dec 31, 2019 at 09:33:14AM -0500, Steven Schveighoffer via > > Digitalmars-d-learn wrote: > > > e.g.: > > > > > > writeln(" Text = ", gr1.map!((ref

Re: What type does byGrapheme() return?

2019-12-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/31/19 2:58 PM, H. S. Teoh wrote: On Tue, Dec 31, 2019 at 09:33:14AM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: e.g.: writeln(" Text = ", gr1.map!((ref g) => g[]).joiner.to!string); [...] Unfortunately this doesn't work. Somehow the ref parameter doesn't match whatever

Re: Finding position of a value in an array

2019-12-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/31/19 2:52 PM, H. S. Teoh wrote: On Tue, Dec 31, 2019 at 09:41:49AM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: On 12/30/19 6:15 PM, JN wrote: On Sunday, 29 December 2019 at 08:31:13 UTC, mipri wrote: int i = a.countUntil!(v => v == 55); assert(i == 2); I also had to

Re: What type does byGrapheme() return?

2019-12-31 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 31, 2019 at 09:33:14AM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: > On 12/30/19 6:31 PM, H. S. Teoh wrote: > > On Mon, Dec 30, 2019 at 03:09:58PM -0800, H. S. Teoh via > > Digitalmars-d-learn wrote: [...] > > Haha, it's actually right there in the Grapheme docs for

Re: Finding position of a value in an array

2019-12-31 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 31, 2019 at 09:41:49AM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote: > On 12/30/19 6:15 PM, JN wrote: > > On Sunday, 29 December 2019 at 08:31:13 UTC, mipri wrote: > > > > > > int i = a.countUntil!(v => v == 55); > > > assert(i == 2); > > > > I also had to ask because I

Re: Finding position of a value in an array

2019-12-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/31/19 9:47 AM, Steven Schveighoffer wrote: for the original example:     int[] a = [77,66,55,44];     int i = a.bwin.find(55).bufRef.pos; sorry, should be size_t i. -Steve

Re: Finding position of a value in an array

2019-12-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/31/19 9:41 AM, Steven Schveighoffer wrote: import std.stdio; import std.algorithm; import bufref; void main() {     string x = "hello, world!";     writeln(x.bwin.find('o').bufRef.pos); } for the original example: int[] a = [77,66,55,44]; int i = a.bwin.find(55).bufRef.pos;

Re: Finding position of a value in an array

2019-12-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/30/19 6:15 PM, JN wrote: On Sunday, 29 December 2019 at 08:31:13 UTC, mipri wrote: int i = a.countUntil!(v => v == 55); assert(i == 2); I also had to ask because I couldn't find it. In other languages it's named "index()", "indexOf()" or "find()". D is the only language I know which

Re: What type does byGrapheme() return?

2019-12-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/30/19 6:31 PM, H. S. Teoh wrote: On Mon, Dec 30, 2019 at 03:09:58PM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] I suspect the cause is that whatever Grapheme.opSlice returns is going out-of-scope when used with .map, that's why it's malfunctioning. [...] Haha, it's actually

Re: Finding position of a value in an array

2019-12-31 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 31 December 2019 at 04:38:53 UTC, Daren Scot Wilson wrote: On Monday, 30 December 2019 at 23:15:48 UTC, JN wrote: On Sunday, 29 December 2019 at 08:31:13 UTC, mipri wrote: int i = a.countUntil!(v => v == 55); assert(i == 2); I also had to ask because I couldn't find it. In other

Re: Finding position of a value in an array

2019-12-31 Thread MoonlightSentinel via Digitalmars-d-learn
On Monday, 30 December 2019 at 23:15:48 UTC, JN wrote: I also had to ask because I couldn't find it. In other languages it's named "index()", "indexOf()" or "find()". D is the only language I know which uses the "countUntil" scheme. And even so it's not obvious from the name if it's the index

Re: Concatenation/joining strings together in a more readable way

2019-12-31 Thread Marcone via Digitalmars-d-learn
On Monday, 30 December 2019 at 14:56:59 UTC, mipri wrote: On Monday, 30 December 2019 at 10:23:14 UTC, Marcone wrote: On Monday, 30 December 2019 at 09:41:55 UTC, mipri wrote: This leaks too much. writeln("Helo {} {}".format("xx", "name")); // Helo xx name writeln("Helo {}

Blog Post #0096: Hardware III - Keyboard and Mouse

2019-12-31 Thread Ron Tarrant via Digitalmars-d-learn
This week's post wraps up the year by looking at how to access keyboard and mouse events through the hardware Seat. You'll find it here: https://gtkdcoding.com/2019/12/31/0096-hardware-iii-keyboard-pointer.html Have a happy New Year, everybody. May 2020 put things into perspective for us

Re: Concatenation/joining strings together in a more readable way

2019-12-31 Thread Marcone via Digitalmars-d-learn
On Monday, 30 December 2019 at 14:56:59 UTC, mipri wrote: On Monday, 30 December 2019 at 10:23:14 UTC, Marcone wrote: On Monday, 30 December 2019 at 09:41:55 UTC, mipri wrote: This leaks too much. writeln("Helo {} {}".format("xx", "name")); // Helo xx name writeln("Helo {}