Re: string-int[] array

2015-03-10 Thread Kagamin via Digitalmars-d-learn
On Sunday, 8 March 2015 at 21:41:44 UTC, FG wrote: Except that with this solution you will confuse empty strings with ints. The idea was to only make it memory-safe without union.

Re: string-int[] array

2015-03-09 Thread ketmar via Digitalmars-d-learn
On Sun, 08 Mar 2015 18:57:37 +, Kagamin wrote: > http://dpaste.dzfl.pl/2c8d4a7d9ef0 like this. i hate annoying beginners too, but not to SUCH extent. signature.asc Description: PGP signature

Re: string-int[] array

2015-03-08 Thread Meta via Digitalmars-d-learn
On Sunday, 8 March 2015 at 21:41:44 UTC, FG wrote: On 2015-03-08 at 20:26, Meta wrote: On Sunday, 8 March 2015 at 18:57:38 UTC, Kagamin wrote: http://dpaste.dzfl.pl/2c8d4a7d9ef0 like this. What in the world is that code doing? I'm having a hard time wrapping my head around this. It's a tri

Re: string-int[] array

2015-03-08 Thread FG via Digitalmars-d-learn
On 2015-03-08 at 20:26, Meta wrote: On Sunday, 8 March 2015 at 18:57:38 UTC, Kagamin wrote: http://dpaste.dzfl.pl/2c8d4a7d9ef0 like this. What in the world is that code doing? I'm having a hard time wrapping my head around this. It's a trick to reuse string internals to store an int. A stri

Re: string-int[] array

2015-03-08 Thread Paul via Digitalmars-d-learn
On Sunday, 8 March 2015 at 21:18:31 UTC, Max Klyga wrote: On 2015-03-08 21:11:42 +, Paul said: On Sunday, 8 March 2015 at 18:05:33 UTC, Dennis Ritchie wrote: Is it possible to create such an array in which you can store strings and numbers at the same time? string-int[] array = [4

Re: string-int[] array

2015-03-08 Thread Dennis Ritchie via Digitalmars-d-learn
On Sunday, 8 March 2015 at 21:18:31 UTC, Max Klyga wrote: OP is fighting a loosing battle in flame war on some obscure forum. F# enthusiast trolls OP into solving stupid puzzles that are trivial in F# (or any ML-family language) and clumsy in C-family languages. In language holy wars the only

Re: string-int[] array

2015-03-08 Thread Max Klyga via Digitalmars-d-learn
On 2015-03-08 21:11:42 +, Paul said: On Sunday, 8 March 2015 at 18:05:33 UTC, Dennis Ritchie wrote: Is it possible to create such an array in which you can store strings and numbers at the same time? string-int[] array = [4, "five"]; As there's no mention of performanc

Re: string-int[] array

2015-03-08 Thread Paul via Digitalmars-d-learn
On Sunday, 8 March 2015 at 18:05:33 UTC, Dennis Ritchie wrote: Is it possible to create such an array in which you can store strings and numbers at the same time? string-int[] array = [4, "five"]; As there's no mention of performance, what's wrong with a plain old string

Re: string-int[] array

2015-03-08 Thread Meta via Digitalmars-d-learn
On Sunday, 8 March 2015 at 18:57:38 UTC, Kagamin wrote: http://dpaste.dzfl.pl/2c8d4a7d9ef0 like this. What in the world is that code doing? I'm having a hard time wrapping my head around this.

Re: string-int[] array

2015-03-08 Thread Baz via Digitalmars-d-learn
On Sunday, 8 March 2015 at 18:54:43 UTC, Meta wrote: On Sunday, 8 March 2015 at 18:38:02 UTC, Dennis Ritchie wrote: On Sunday, 8 March 2015 at 18:18:15 UTC, Baz wrote: import std.stdio; import std.typecons; alias T = Tuple!(string, int); void main(string[] args) { T[] tarr; tarr ~= T("a",

Re: string-int[] array

2015-03-08 Thread Dennis Ritchie via Digitalmars-d-learn
On Sunday, 8 March 2015 at 18:54:43 UTC, Meta wrote: On Sunday, 8 March 2015 at 18:38:02 UTC, Dennis Ritchie wrote: On Sunday, 8 March 2015 at 18:18:15 UTC, Baz wrote: import std.stdio; import std.typecons; alias T = Tuple!(string, int); void main(string[] args) { T[] tarr; tarr ~= T("a",

Re: string-int[] array

2015-03-08 Thread Kagamin via Digitalmars-d-learn
http://dpaste.dzfl.pl/2c8d4a7d9ef0 like this.

Re: string-int[] array

2015-03-08 Thread Meta via Digitalmars-d-learn
On Sunday, 8 March 2015 at 18:38:02 UTC, Dennis Ritchie wrote: On Sunday, 8 March 2015 at 18:18:15 UTC, Baz wrote: import std.stdio; import std.typecons; alias T = Tuple!(string, int); void main(string[] args) { T[] tarr; tarr ~= T("a",65); tarr ~= T("b",66); writeln(tarr); }

Re: string-int[] array

2015-03-08 Thread Dennis Ritchie via Digitalmars-d-learn
ay of union ? string-int[] array; a = [5, "v", 4, "t", "a", "b", 7, 9, 10, 15, "example"]; writeln(a); // [5, "v", 4, "t", "a", "b", 7, 9, 10, 15, "example"]

Re: string-int[] array

2015-03-08 Thread Dennis Ritchie via Digitalmars-d-learn
On Sunday, 8 March 2015 at 18:18:15 UTC, Baz wrote: import std.stdio; import std.typecons; alias T = Tuple!(string, int); void main(string[] args) { T[] tarr; tarr ~= T("a",65); tarr ~= T("b",66); writeln(tarr); } [Tuple!(string, int)("a", 65), Tuple!(string, int)("b", 66

Re: string-int[] array

2015-03-08 Thread Baz via Digitalmars-d-learn
On Sunday, 8 March 2015 at 18:18:15 UTC, Baz wrote: On Sunday, 8 March 2015 at 18:05:33 UTC, Dennis Ritchie wrote: Is it possible to create such an array in which you can store strings and numbers at the same time? string-int[] array = [4, "five"]; using an array of tupl

Re: string-int[] array

2015-03-08 Thread Baz via Digitalmars-d-learn
On Sunday, 8 March 2015 at 18:05:33 UTC, Dennis Ritchie wrote: Is it possible to create such an array in which you can store strings and numbers at the same time? string-int[] array = [4, "five"]; using an array of tuple it works: import std.stdio; import std.typecons; alias

string-int[] array

2015-03-08 Thread Dennis Ritchie via Digitalmars-d-learn
Is it possible to create such an array in which you can store strings and numbers at the same time? string-int[] array = [4, "five"];