Re: How to create a mutable array of strings?

2015-05-18 Thread Dennis Ritchie via Digitalmars-d-learn
On Monday, 18 May 2015 at 13:14:38 UTC, Steven Schveighoffer wrote: It's annoying to have to dup each one. Yes, it's really annoying. However, the problem can be solved as follows:

Re: How to create a mutable array of strings?

2015-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/15 9:55 AM, Dennis Ritchie wrote: On Monday, 18 May 2015 at 13:14:38 UTC, Steven Schveighoffer wrote: It's annoying to have to dup each one. Yes, it's really annoying. However, the problem can be solved as follows:

Re: How to create a mutable array of strings?

2015-05-18 Thread Dennis Ritchie via Digitalmars-d-learn
On Monday, 18 May 2015 at 14:43:33 UTC, Steven Schveighoffer wrote: Right, you'd apply the map/array combo to each element: Yes, I knew it. alias m = map!(a = a.dup); // too bad can't do array as well auto s = [m([foo, baz]).array, m([bar, test]).array]; Or to get even more crazy: auto s

Re: How to create a mutable array of strings?

2015-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/17/15 5:15 AM, Dennis Ritchie wrote: This option is also a strange: char[][] s = [foo.dup, bar.dup]; s[1][1] = 't'; In my opinion, you need to add to D keyword mutable. It's annoying to have to dup each one. But, you do have a couple other possibilities: auto s = [foo.dup, bar.dup];

Re: How to create a mutable array of strings?

2015-05-17 Thread Dennis Ritchie via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:06:40 UTC, Dennis Ritchie wrote: Hi, It seems to me, or D do not create mutable array of strings? How to create a mutable equivalent of a string array? - string[] s = [foo, bar]; // s[1][1] = 't'; // immutable expression s[1][1] It's uncomfortable: - char

How to create a mutable array of strings?

2015-05-17 Thread Dennis Ritchie via Digitalmars-d-learn
Hi, It seems to me, or D do not create mutable array of strings? How to create a mutable equivalent of a string array? - string[] s = [foo, bar]; // s[1][1] = 't'; // immutable expression s[1][1]

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sun, 17 May 2015 09:06:38 + Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi, It seems to me, or D do not create mutable array of strings? How to create a mutable equivalent of a string array? - string[] s = [foo, bar]; // s[1][1] = 't

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sun, 17 May 2015 09:06:38 + Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi, It seems to me, or D do not create mutable array of strings? How to create a mutable equivalent of a string array? - string[] s = [foo, bar]; // s[1][1] = 't

Re: How to create a mutable array of strings?

2015-05-17 Thread Dennis Ritchie via Digitalmars-d-learn
This option is also a strange: char[][] s = [foo.dup, bar.dup]; s[1][1] = 't'; In my opinion, you need to add to D keyword mutable.

Re: How to create a mutable array of strings?

2015-05-17 Thread Jack Applegame via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:10:06 UTC, Dennis Ritchie wrote: It's uncomfortable: - char[][] s = [['f', 'o', 'o'], ['b', 'a', 'r']]; s[1][1] = 't'; auto s = [foo.dup, bar.dup]; s[1][1] = 't';

Re: How to create a mutable array of strings?

2015-05-17 Thread Dennis Ritchie via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:18:15 UTC, Daniel Kozak wrote: auto s = cast(char[][])[foo, bar]; Thanks. This version I was completely satisfied.

Re: How to create a mutable array of strings?

2015-05-17 Thread anonymous via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:20:17 UTC, Dennis Ritchie wrote: On Sunday, 17 May 2015 at 09:18:15 UTC, Daniel Kozak wrote: auto s = cast(char[][])[foo, bar]; Thanks. This version I was completely satisfied. Remember that Daniel Kozak wrote if you are sure thats what you really need. I'm

Re: How to create a mutable array of strings?

2015-05-17 Thread via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:18:15 UTC, Daniel Kozak wrote: On Sun, 17 May 2015 09:06:38 + Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi, It seems to me, or D do not create mutable array of strings? How to create a mutable equivalent of a string

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:18:15 UTC, Daniel Kozak wrote: On Sun, 17 May 2015 09:06:38 + Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi, It seems to me, or D do not create mutable array of strings? How to create a mutable equivalent of a string

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:21:58 UTC, Marc Schütz wrote: On Sunday, 17 May 2015 at 09:18:15 UTC, Daniel Kozak wrote: On Sun, 17 May 2015 09:06:38 + Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi, It seems to me, or D do not create mutable array

Re: How to create a mutable array of strings?

2015-05-17 Thread Dennis Ritchie via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:24:19 UTC, anonymous wrote: On Sunday, 17 May 2015 at 09:20:17 UTC, Dennis Ritchie wrote: On Sunday, 17 May 2015 at 09:18:15 UTC, Daniel Kozak wrote: auto s = cast(char[][])[foo, bar]; Thanks. This version I was completely satisfied. Remember that Daniel Kozak

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:20:17 UTC, Dennis Ritchie wrote: On Sunday, 17 May 2015 at 09:18:15 UTC, Daniel Kozak wrote: auto s = cast(char[][])[foo, bar]; Thanks. This version I was completely satisfied. So maybe this one would be ok with you too :) auto s = to!(char[][])([foo, bar]);

Re: How to create a mutable array of strings?

2015-05-17 Thread Dennis Ritchie via Digitalmars-d-learn
I remembered code Ali Çereli. It really helped: http://forum.dlang.org/thread/ulhtlyxxclihaseef...@forum.dlang.org#post-mihl6m:241che:241:40digitalmars.com - import std.stdio, std.traits, std.range, std.algorithm; auto deepDup(A)(A arr) if (isArray!A) { static if

Re: How to create a mutable array of strings?

2015-05-17 Thread anonymous via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:26:15 UTC, Dennis Ritchie wrote: And no crashes on Windows :) Yeah, on windows it's even worse. void main() { auto s = cast(char[][])[foo, bar]; s[1][1] = 't'; import std.stdio; writeln(bar); }

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sun, 17 May 2015 09:39:21 + Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I remembered code Ali Çereli. It really helped: http://forum.dlang.org/thread/ulhtlyxxclihaseef...@forum.dlang.org#post-mihl6m:241che:241:40digitalmars.com - import

Re: How to create a mutable array of strings?

2015-05-17 Thread Dennis Ritchie via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:36:33 UTC, anonymous wrote: On Sunday, 17 May 2015 at 09:26:15 UTC, Dennis Ritchie wrote: And no crashes on Windows :) Yeah, on windows it's even worse. void main() { auto s = cast(char[][])[foo, bar]; s[1][1] = 't'; import std.stdio;

Re: How to create a mutable array of strings?

2015-05-17 Thread Dennis Ritchie via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:37:56 UTC, Daniel Kozak wrote: So maybe this one would be ok with you too :) auto s = to!(char[][])([foo, bar]); Now it works :)

Re: How to create a mutable array of strings?

2015-05-17 Thread Daniel Kozak via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:57:05 UTC, Daniel Kozak wrote: On Sun, 17 May 2015 09:39:21 + Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I remembered code Ali Çereli. It really helped:

Re: How to create a mutable array of strings?

2015-05-17 Thread Dennis Ritchie via Digitalmars-d-learn
On Sunday, 17 May 2015 at 10:05:34 UTC, Daniel Kozak wrote: Ouch ignore this one :D Yes, it will not work with multidimensional arrays :)