Reversing a string

2019-01-11 Thread AndreasDavour via Digitalmars-d-learn
Hi. I've just started to learn some D, so maybe this question is extremely stupid, but please bear with me. I have been trying to reverse a string, and through some googling found the std.algorithm.mutation.reverse method. But, when I try to use it I get some very verbose errors that just

Re: Reversing a string

2019-01-11 Thread Seb via Digitalmars-d-learn
On Friday, 11 January 2019 at 08:05:39 UTC, AndreasDavour wrote: Hi. I've just started to learn some D, so maybe this question is extremely stupid, but please bear with me. [...] Use .retro - it is also lazy and won't allocate: https://run.dlang.io/is/A6bjrC

Re: Reversing a string

2019-01-11 Thread AndreasDavour via Digitalmars-d-learn
On Friday, 11 January 2019 at 08:45:12 UTC, JN wrote: On Friday, 11 January 2019 at 08:15:01 UTC, rikki cattermole wrote: Note the immutable, it means you cannot modify individual values. Which is a problem for reverse because it modifies in place. The error message is kind of unfortunate.

Packing 5-bit words into size_t-aligned bit-array

2019-01-11 Thread Per Nordlöw via Digitalmars-d-learn
I want to pack a letters from a char[] into an array of 5-bit encoded English lower letters in a size_t[2]. How do I accomplish that with as few instructions as possible? I currently have size_t[2] words; enum charBits = 5; foreach (const ch_index, const char ch; expr)

Re: Reversing a string

2019-01-11 Thread rikki cattermole via Digitalmars-d-learn
So strings in D are Unicode. This is both a great thing and a horrible thing. To reverse a Unicode string correctly you need to take into account BiDi and graphemes, in other words it gets rather complex. However I suspect that this isn't what you want. Now a (w/d)string is defined as: alias

Re: Reversing a string

2019-01-11 Thread JN via Digitalmars-d-learn
On Friday, 11 January 2019 at 08:15:01 UTC, rikki cattermole wrote: Note the immutable, it means you cannot modify individual values. Which is a problem for reverse because it modifies in place. The error message is kind of unfortunate. This is a simple usecase and the error message is

Re: Segfault when adding a static destructor in druntime/src/rt/sections_elf_shared.d

2019-01-11 Thread RazvanN via Digitalmars-d-learn
On Thursday, 10 January 2019 at 23:04:37 UTC, Steven Schveighoffer wrote: On 1/10/19 5:12 PM, RazvanN wrote: On Thursday, 10 January 2019 at 15:04:25 UTC, Steven Schveighoffer wrote: On 1/8/19 7:54 AM, RazvanN wrote: [...] That is a thread-local static destructor. Are any shared static

Re: Reversing a string

2019-01-11 Thread bauss via Digitalmars-d-learn
On Friday, 11 January 2019 at 08:25:41 UTC, Seb wrote: On Friday, 11 January 2019 at 08:05:39 UTC, AndreasDavour wrote: Hi. I've just started to learn some D, so maybe this question is extremely stupid, but please bear with me. [...] Use .retro - it is also lazy and won't allocate:

Re: Reversing a string

2019-01-11 Thread AndreasDavour via Digitalmars-d-learn
On Friday, 11 January 2019 at 09:41:30 UTC, bauss wrote: On Friday, 11 January 2019 at 08:25:41 UTC, Seb wrote: On Friday, 11 January 2019 at 08:05:39 UTC, AndreasDavour wrote: Hi. I've just started to learn some D, so maybe this question is extremely stupid, but please bear with me. [...]

Re: Reversing a string

2019-01-11 Thread bauss via Digitalmars-d-learn
On Friday, 11 January 2019 at 11:15:05 UTC, Mike James wrote: On Friday, 11 January 2019 at 09:41:30 UTC, bauss wrote: On Friday, 11 January 2019 at 08:25:41 UTC, Seb wrote: On Friday, 11 January 2019 at 08:05:39 UTC, AndreasDavour wrote: Hi. I've just started to learn some D, so maybe this

Re: SerialPort

2019-01-11 Thread UlanReed via Digitalmars-d-learn
For me https://www.virtual-serial-port.org/products/serialmonitor/ is an ideal way to track down problems that may occur during application or driver development, testing and optimization of serial devices and i use this soft all time.

Re: Reversing a string

2019-01-11 Thread AndreasDavour via Digitalmars-d-learn
On Friday, 11 January 2019 at 11:15:05 UTC, Mike James wrote: On Friday, 11 January 2019 at 09:41:30 UTC, bauss wrote: On Friday, 11 January 2019 at 08:25:41 UTC, Seb wrote: On Friday, 11 January 2019 at 08:05:39 UTC, AndreasDavour wrote: Hi. I've just started to learn some D, so maybe this

Re: Reversing a string

2019-01-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 January 2019 at 13:51:04 UTC, JN wrote: I guess something like iterReverse, reverseIter, backIterator would be too simple... or foreach_reverse, which never actually was removed! lol

Re: Reversing a string

2019-01-11 Thread Mike James via Digitalmars-d-learn
On Friday, 11 January 2019 at 09:41:30 UTC, bauss wrote: On Friday, 11 January 2019 at 08:25:41 UTC, Seb wrote: On Friday, 11 January 2019 at 08:05:39 UTC, AndreasDavour wrote: Hi. I've just started to learn some D, so maybe this question is extremely stupid, but please bear with me. [...]

Re: Reversing a string

2019-01-11 Thread JN via Digitalmars-d-learn
On Friday, 11 January 2019 at 11:15:05 UTC, Mike James wrote: Check out the origin :-) https://forum.dlang.org/thread/hl8345$2b1q$1...@digitalmars.com?page=1 I guess something like iterReverse, reverseIter, backIterator would be too simple...

Re: Creating fixed array on stack

2019-01-11 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 11 January 2019 at 15:23:08 UTC, Dgame wrote: On Friday, 11 January 2019 at 14:46:36 UTC, Andrey wrote: Hi, In C++ you can create a fixed array on stack: int count = getCount(); int myarray[count]; Small correction: this is valid in C, but not in C++. In D the "count" is part of

Re: Filter and sort associative array

2019-01-11 Thread Head Scratcher via Digitalmars-d-learn
On Friday, 11 January 2019 at 16:06:48 UTC, Alex wrote: On Friday, 11 January 2019 at 16:02:27 UTC, Head Scratcher wrote: Thank you. This works great. What I don't understand is how a key-value pair ends up being a set of strings. Where did the value of the key-value pair get removed?

Re: All these errors running basic Pegged helloworld example.

2019-01-11 Thread Michelle Long via Digitalmars-d-learn
On Sunday, 27 September 2015 at 06:30:37 UTC, Enjoys Math wrote: The example is: import pegged.grammar; mixin(grammar(` Arithmetic: Term < Factor (Add / Sub)* Add < "+" Factor Sub < "-" Factor Factor < Primary (Mul / Div)* Mul < "*" Primary Div

Re: All these errors running basic Pegged helloworld example.

2019-01-11 Thread Enjoys Math via Digitalmars-d-learn
On Sunday, 27 September 2015 at 07:16:51 UTC, BBasile wrote: On Sunday, 27 September 2015 at 06:30:37 UTC, Enjoys Math wrote: The example is: import pegged.grammar; mixin(grammar(` Arithmetic: Term < Factor (Add / Sub)* Add < "+" Factor Sub < "-" Factor Factor

Re: Coedit almost works for me, except when I go to add peggged

2019-01-11 Thread Neia Neutuladh via Digitalmars-d-learn
On Fri, 11 Jan 2019 17:25:29 +, Enjoys Math wrote: > Package peggged not found for registry at https://code.dlang.org/ The package name is pegged, not peggged. Two g's, not three.

Print a copyright symbol

2019-01-11 Thread Head Scratcher via Digitalmars-d-learn
How would I use writeln to print a copyright symbol to the console? I have tried using the unicode code \u00A9, as well as embedding the symbol directly in the string, but I just get garbage when I run it.

Re: Print a copyright symbol

2019-01-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 January 2019 at 16:48:40 UTC, Head Scratcher wrote: How would I use writeln to print a copyright symbol to the console? I have tried using the unicode code \u00A9, as well as embedding the symbol directly in the string, but I just get garbage when I run it. You need to be using

dub generate visuald shits on me

2019-01-11 Thread Enjoys Math via Digitalmars-d-learn
I do: dub init simple_type_theory cd simple_type_theory dub generate visuald Errors: C:\Users\FruitfulApproach\Desktop\_SIMPLE_TYPE_THEORY\simple_type_theory>dub generate visuald simple_type_theory Building package simple_type_theory in

Coedit almost works for me, except when I go to add peggged

2019-01-11 Thread Enjoys Math via Digitalmars-d-learn
I open up the Library Manager in Coedit. I click on the DUB icon. I enter in 'pegged' then click the green check. Errors: Package peggged not found for registry at https://code.dlang.org/ (fallback ["registry at http://code.dlang.org/;, "registry at https://code-mirror.dlang.io/;, "registry

Re: All these errors running basic Pegged helloworld example.

2019-01-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/11/19 1:21 PM, Enjoys Math wrote: On Friday, 11 January 2019 at 17:44:33 UTC, Michelle Long wrote: On Sunday, 27 September 2015 at 06:30:37 UTC, Enjoys Math wrote: [...] You need to add most of the pegged files... there are more than 3. Try adding them all first then remove the junk

Re: Generating API documention

2019-01-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 10 January 2019 at 07:04:52 UTC, George wrote: What do people use to generate nice looking and simple html documentation for their projects? If you like my style and syntax

Re: Filter and sort associative array

2019-01-11 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 11, 2019 at 03:20:20PM +, Head Scratcher via Digitalmars-d-learn wrote: > I am just learning D. So far, I am impressed by its elegance and power. > > I have an associative array bool[string]. I want to filter it by value > (!bool), then extract the keys and sort them. I am

Re: Filter and sort associative array

2019-01-11 Thread Head Scratcher via Digitalmars-d-learn
Thank you. This works great. What I don't understand is how a key-value pair ends up being a set of strings. Where did the value of the key-value pair get removed? According to the library documentation, the array function "allocates an array and initializes it with copies of the elements of

Re: Creating fixed array on stack

2019-01-11 Thread Dgame via Digitalmars-d-learn
On Friday, 11 January 2019 at 14:46:36 UTC, Andrey wrote: Hi, In C++ you can create a fixed array on stack: int count = getCount(); int myarray[count]; In D the "count" is part of type and must be known at CT but in example it is RT. How to do such thing in D? Without using of heap. You

Filter and sort associative array

2019-01-11 Thread Head Scratcher via Digitalmars-d-learn
I am just learning D. So far, I am impressed by its elegance and power. I have an associative array bool[string]. I want to filter it by value (!bool), then extract the keys and sort them. I am struggling with the syntax and working with ranges. I can't find any documentation related to

Creating fixed array on stack

2019-01-11 Thread Andrey via Digitalmars-d-learn
Hi, In C++ you can create a fixed array on stack: int count = getCount(); int myarray[count]; In D the "count" is part of type and must be known at CT but in example it is RT. How to do such thing in D? Without using of heap.

Re: Filter and sort associative array

2019-01-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/11/19 10:20 AM, Head Scratcher wrote: I am just learning D. So far, I am impressed by its elegance and power. I have an associative array bool[string]. I want to filter it by value (!bool), then extract the keys and sort them. I am struggling with the syntax and working with ranges. I

Re: Filter and sort associative array

2019-01-11 Thread Alex via Digitalmars-d-learn
On Friday, 11 January 2019 at 16:02:27 UTC, Head Scratcher wrote: Thank you. This works great. What I don't understand is how a key-value pair ends up being a set of strings. Where did the value of the key-value pair get removed? According to the library documentation, the array function

Re: All these errors running basic Pegged helloworld example.

2019-01-11 Thread Enjoys Math via Digitalmars-d-learn
On Friday, 11 January 2019 at 17:44:33 UTC, Michelle Long wrote: On Sunday, 27 September 2015 at 06:30:37 UTC, Enjoys Math wrote: [...] You need to add most of the pegged files... there are more than 3. Try adding them all first then remove the junk like the examples, docs, etc until it

Has anyone tried making a QtCreator plugin for D and what is your experience?

2019-01-11 Thread Enjoys Math via Digitalmars-d-learn
I'm 5 years an expert at PyQt5 in conjunction with QtCreator-designed widgets. Where D is lacking is a good GUI editor and GUI library support. I am starting by building a python-based project called QDmt = Qt/D manager It will do for you, in a cross-platform way, the laborious task of

Re: Reversing a string

2019-01-11 Thread AlCaponeJr via Digitalmars-d-learn
On Friday, 11 January 2019 at 11:15:05 UTC, Mike James wrote: Check out the origin :-) https://forum.dlang.org/thread/hl8345$2b1q$1...@digitalmars.com?page=1 Indeed a terrible name, please don't tell me this was chosen by vote. By the way currently is there any vote system for naming these

Re: UTFException when reading a file

2019-01-11 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 11, 2019 at 07:45:05PM +, Head Scratcher via Digitalmars-d-learn wrote: > I am using readText to read a file into a string. I am getting a > UTFException on the file. It is probably because the file has an > extended ANSI character that is not UTF-8. > How can I read the file and

Re: Coedit almost works for me, except when I go to add peggged

2019-01-11 Thread Enjoys Math via Digitalmars-d-learn
On Friday, 11 January 2019 at 17:38:31 UTC, Neia Neutuladh wrote: On Fri, 11 Jan 2019 17:25:29 +, Enjoys Math wrote: Package peggged not found for registry at https://code.dlang.org/ The package name is pegged, not peggged. Two g's, not three. Dude, that doesn't work either. lol

Re: Reversing a string

2019-01-11 Thread 0xEAB via Digitalmars-d-learn
On Friday, 11 January 2019 at 13:51:04 UTC, JN wrote: On Friday, 11 January 2019 at 11:15:05 UTC, Mike James wrote: Check out the origin :-) https://forum.dlang.org/thread/hl8345$2b1q$1...@digitalmars.com?page=1 I guess something like iterReverse, reverseIter, backIterator would be too

Re: Coedit almost works for me, except when I go to add peggged

2019-01-11 Thread 0xEAB via Digitalmars-d-learn
On Friday, 11 January 2019 at 18:27:37 UTC, Enjoys Math wrote: Dude, that doesn't work either. lol If you're using DUB, add the dependency manually to your project: "dependencies": {"pegged": "~>0.4.4"}

Re: Coedit almost works for me, except when I go to add peggged

2019-01-11 Thread Enjoys Math via Digitalmars-d-learn
On Friday, 11 January 2019 at 18:36:18 UTC, 0xEAB wrote: On Friday, 11 January 2019 at 18:27:37 UTC, Enjoys Math wrote: Dude, that doesn't work either. lol If you're using DUB, add the dependency manually to your project: "dependencies": {"pegged": "~>0.4.4"} You will have to be more

Re: UTFException when reading a file

2019-01-11 Thread Dennis via Digitalmars-d-learn
On Friday, 11 January 2019 at 19:45:05 UTC, Head Scratcher wrote: How can I read the file and convert the string into proper UTF-8 in memory without an exception? You have multiple options: ``` import std.file: read; import std.encoding: transcode, Windows1252String; auto ansiStr =

Re: All these errors running basic Pegged helloworld example.

2019-01-11 Thread 0xEAB via Digitalmars-d-learn
On Friday, 11 January 2019 at 17:35:40 UTC, Enjoys Math wrote: Thanks, I downloaded Coedit, but it's not working with pegged (using the library manager dub button) According to your post in [0], it didn't work because you had a typo in `pegged`. Maybe correct it and try again :) - Elias

Re: Reversing a string

2019-01-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/11/19 1:25 PM, 0xEAB wrote: On Friday, 11 January 2019 at 13:51:04 UTC, JN wrote: On Friday, 11 January 2019 at 11:15:05 UTC, Mike James wrote: Check out the origin :-) https://forum.dlang.org/thread/hl8345$2b1q$1...@digitalmars.com?page=1 I guess something like iterReverse,

UTFException when reading a file

2019-01-11 Thread Head Scratcher via Digitalmars-d-learn
I am using readText to read a file into a string. I am getting a UTFException on the file. It is probably because the file has an extended ANSI character that is not UTF-8. How can I read the file and convert the string into proper UTF-8 in memory without an exception?

Re: UTFException when reading a file

2019-01-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 January 2019 at 19:45:05 UTC, Head Scratcher wrote: How can I read the file and convert the string into proper UTF-8 in memory without an exception? Use regular read() instead of readText, and then convert it use another function. Phobos has std.encoding which offers a

Re: Getting template parameters by its name

2019-01-11 Thread Yui Hosaka via Digitalmars-d-learn
On Friday, 11 January 2019 at 06:13:11 UTC, Paul Backus wrote: On Friday, 11 January 2019 at 04:59:50 UTC, Yui Hosaka wrote: I want to do something like this: template S(T) { } void main() { pragma(msg, S!(int).T); // Error: no property `T` for type `void` } You can get the