Re: String concatenation segmentation error

2021-04-23 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 22 April 2021 at 21:15:48 UTC, tcak wrote: string fileContent = ""; ... [...] Do you have a minimal reproducible test case? 樂

Re: String concatenation segmentation error

2021-04-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 23 April 2021 at 00:44:58 UTC, tcak wrote: As far as I see, it is not related to that array or indices at all. The question of where is to see if it was CTFE allocated or runtime allocated. I don't think it should make a difference here but idk. If there is no known situation

Re: String concatenation segmentation error

2021-04-22 Thread tcak via Digitalmars-d-learn
all. Oh and *where* is that positions variable defined? I am doing OpenCL programming. CPU side is single threaded. As far as I see, it is not related to that array or indices at all. After running for a short time, if a piece of code does any string/char or byte array concatenation at al

Re: String concatenation segmentation error

2021-04-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 22 April 2021 at 21:15:48 UTC, tcak wrote: "positions" array is defined as auto positions = new float[ 100 ]; So, I am 100% sure, it is not out of range. "ri*dim + 1" is not a big number at all. Oh and *where* is that positions variable defined?

Re: String concatenation segmentation error

2021-04-22 Thread Adam D. Ruppe via Digitalmars-d-learn
Are there any other threads in your program?

Re: String concatenation segmentation error

2021-04-22 Thread tcak via Digitalmars-d-learn
In other parts of the code, concatenation operations are all failing with same error. I need guidance to get out of this situation. My assumption was that as long as there is empty heap memory, concatenation operation would succeed always. But, it doesn't seem like so.

String concatenation segmentation error

2021-04-22 Thread tcak via Digitalmars-d-learn
ll allocation. I remember I had this problem before in another project. I have enough free ram. htop shows 3.96 GiB of 8 GiB is used only and swap is not in use. DMD64 D Compiler v2.094.0 Is this error related to me? Is it a programmer error? Is it a bug? Am I doing something wrong? This is a compiler related operation (string concatenation), and I assume/expect that it would work without a problem.

Re: Asking about performance of std concatenation vs. Appender vs. custom class

2021-04-09 Thread ludo via Digitalmars-d-learn
reserving cuts down on the reallocations, but that only takes some of the time. Appending a 1000-element int array is going to go from a 16-byte block, to a 32-byte block, etc. up to a 4096 byte block. This involves roughly 8 reallocations per test. But every append requires an opaque

Re: Asking about performance of std concatenation vs. Appender vs. custom class

2021-04-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/1/21 10:53 AM, ludo wrote: The results are below (you can also git clone the repo + dub test): | Concatenation method | benchmark in ms| |-|-| |with std:    | 385 ms| |with stdReserve: | 327 ms| |with stdLength:  | 29 ms

Asking about performance of std concatenation vs. Appender vs. custom class

2021-04-01 Thread ludo via Digitalmars-d-learn
with concatenation at the expense of the base pointer being 4 system words instead of two (16 instead of 8 bytes on a 32-bit system). */ ``` So I wrote a unittest to verify that claim, using for benchmark 10_000_000 concatenations : ```d trace("*** ArrayBuilder Concatenation benc

Re: Dude about ~ array concatenation performance

2020-12-02 Thread ddcovery via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 06:31:49 UTC, H. S. Teoh wrote: On Tue, Dec 01, 2020 at 10:49:55PM +, ddcovery via Digitalmars-d-learn wrote: Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! [...] With

Re: Dude about ~ array concatenation performance

2020-12-01 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 01, 2020 at 10:49:55PM +, ddcovery via Digitalmars-d-learn wrote: > Yesterday I really shocked when, comparing one algorithm written in > javascript and the equivalent in D, javascript performed better!!! [...] > With 1 million Double numbers (generated randomly): > Javascript

Re: Doubts about the performance of array concatenation

2020-12-01 Thread Max Haughton via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 00:08:55 UTC, ddcovery wrote: On Tuesday, 1 December 2020 at 23:43:31 UTC, Max Haughton wrote: On Tuesday, 1 December 2020 at 22:49:55 UTC, ddcovery wrote: Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D,

Re: Doubts about the performance of array concatenation

2020-12-01 Thread ddcovery via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 23:43:31 UTC, Max Haughton wrote: On Tuesday, 1 December 2020 at 22:49:55 UTC, ddcovery wrote: Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! [...] Use ldc, rdmd can

Re: Dude about ~ array concatenation performance

2020-12-01 Thread Max Haughton via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 22:49:55 UTC, ddcovery wrote: Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! [...] Use ldc, rdmd can invoke it for you. DMD's optimizer is not even close to as advanced as

Re: Doubts about the performance of array concatenation

2020-12-01 Thread ddcovery via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 22:49:55 UTC, ddcovery wrote: Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! [...] Sorry about title (may be "doubt" :-/ )

Dude about ~ array concatenation performance

2020-12-01 Thread ddcovery via Digitalmars-d-learn
Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! The idea is to translate the "3 lines sort" in haskell to Javascript and D (with the limitations of each language). This is not a quick sort test, but a

Re: Type sequence concatenation / associative array implementation

2020-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/12/20 5:47 PM, Paul Backus wrote: On Wednesday, 12 February 2020 at 20:58:49 UTC, Marcel wrote: 2- How is the builtin associative array implemented? I think I read somewhere it's implemented like C++'s std::unordered_map but with BSTs instead of DLists for handling collisions: is this

Re: Type sequence concatenation / associative array implementation

2020-02-12 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 12 February 2020 at 20:58:49 UTC, Marcel wrote: 2- How is the builtin associative array implemented? I think I read somewhere it's implemented like C++'s std::unordered_map but with BSTs instead of DLists for handling collisions: is this correct? It's an open-addressed hash

Re: Type sequence concatenation / associative array implementation

2020-02-12 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Feb 12, 2020 at 09:05:22PM +, user1234 via Digitalmars-d-learn wrote: > On Wednesday, 12 February 2020 at 20:58:49 UTC, Marcel wrote: > > Hello! > > I have two questions: > > > > 1- How can I concatenate two type sequences? > > alias Concatenated = AliasSeq!(TList1, TList2); [...]

Re: Type sequence concatenation / associative array implementation

2020-02-12 Thread user1234 via Digitalmars-d-learn
On Wednesday, 12 February 2020 at 20:58:49 UTC, Marcel wrote: Hello! I have two questions: 1- How can I concatenate two type sequences? alias Concatenated = AliasSeq!(TList1, TList2); or maybe alias Concatenated = AliasSeq!(TList1[0..$], TList2[0..$]); since I don't remember if they nest

Type sequence concatenation / associative array implementation

2020-02-12 Thread Marcel via Digitalmars-d-learn
Hello! I have two questions: 1- How can I concatenate two type sequences? 2- How is the builtin associative array implemented? I think I read somewhere it's implemented like C++'s std::unordered_map but with BSTs instead of DLists for handling collisions: is this correct?

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

2020-01-02 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 25 December 2019 at 12:39:08 UTC, BoQsc wrote: Are there any other ways to join two strings without Tilde ~ character? I can't seems to find anything about Tilde character concatenation easily, nor the alternatives to it. Can someone share some knowledge on this or at least point

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

2020-01-02 Thread Marcone via Digitalmars-d-learn
On Wednesday, 25 December 2019 at 12:39:08 UTC, BoQsc wrote: Are there any other ways to join two strings without Tilde ~ character? I can't seems to find anything about Tilde character concatenation easily, nor the alternatives to it. Can someone share some knowledge on this or at least point

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

2020-01-01 Thread Marcone via Digitalmars-d-learn
On Wednesday, 25 December 2019 at 12:39:08 UTC, BoQsc wrote: Are there any other ways to join two strings without Tilde ~ character? I can't seems to find anything about Tilde character concatenation easily, nor the alternatives to it. Can someone share some knowledge on this or at least point

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 {}

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 {}

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

2019-12-30 Thread mipri via Digitalmars-d-learn
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 {} {}".format("{}", "name")); // Helo name {} This function replace {}

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

2019-12-30 Thread Marcone via Digitalmars-d-learn
On Monday, 30 December 2019 at 09:41:55 UTC, mipri wrote: On Monday, 30 December 2019 at 06:47:37 UTC, Marcone wrote: Use Python format() style: import std; import std: Format = format; // format() string format(T...)(T text){ string texto = text[0]; foreach(count, i;

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

2019-12-30 Thread mipri via Digitalmars-d-learn
On Monday, 30 December 2019 at 06:47:37 UTC, Marcone wrote: Use Python format() style: import std; import std: Format = format; // format() string format(T...)(T text){ string texto = text[0]; foreach(count, i; text[1..$]){ texto = texto.replaceFirst("{}",

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

2019-12-29 Thread Marcone via Digitalmars-d-learn
On Wednesday, 25 December 2019 at 13:07:44 UTC, mipri wrote: On Wednesday, 25 December 2019 at 12:39:08 UTC, BoQsc wrote: Are there any other ways to join two strings without Tilde ~ character? I can't seems to find anything about Tilde character concatenation easily, nor the alternatives

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

2019-12-25 Thread mipri via Digitalmars-d-learn
On Wednesday, 25 December 2019 at 12:39:08 UTC, BoQsc wrote: Are there any other ways to join two strings without Tilde ~ character? I can't seems to find anything about Tilde character concatenation easily, nor the alternatives to it. Can someone share some knowledge on this or at least point

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

2019-12-25 Thread Tobias Pankrath via Digitalmars-d-learn
On Wednesday, 25 December 2019 at 12:39:08 UTC, BoQsc wrote: Are there any other ways to join two strings without Tilde ~ character? I can't seems to find anything about Tilde character concatenation easily, nor the alternatives to it. Can someone share some knowledge on this or at least point

Concatenation/joining strings together in a more readable way

2019-12-25 Thread BoQsc via Digitalmars-d-learn
Are there any other ways to join two strings without Tilde ~ character? I can't seems to find anything about Tilde character concatenation easily, nor the alternatives to it. Can someone share some knowledge on this or at least point out useful links/resources?

Re: How array concatenation works... internally

2018-04-23 Thread Dnewbie via Digitalmars-d-learn
On Monday, 23 April 2018 at 23:27:17 UTC, Steven Schveighoffer wrote: ... If you want to know more about the array runtime, I suggest this article: https://dlang.org/articles/d-array-article.html ... Thanks for replying and this article is what I was looking for.

Re: How array concatenation works... internally

2018-04-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/23/18 7:15 PM, Dnewbie wrote: Hi, I'd like to understand how array concatenation works internally, like the example below: //DMD64 D Compiler 2.072.2 import std.stdio; void main(){     string[] arr;     arr.length = 2;     arr[0] = "Hello";     arr[1] = "World

Re: How array concatenation works... internally

2018-04-23 Thread Dnewbie via Digitalmars-d-learn
On Monday, 23 April 2018 at 23:15:13 UTC, Dnewbie wrote: It's related to memcpy? By the way... It's related to realloc and memcpy?

How array concatenation works... internally

2018-04-23 Thread Dnewbie via Digitalmars-d-learn
Hi, I'd like to understand how array concatenation works internally, like the example below: //DMD64 D Compiler 2.072.2 import std.stdio; void main(){ string[] arr; arr.length = 2; arr[0] = "Hello"; arr[1] = "World"; writeln(arr.length); arr = arr

Re: nogc string concatenation?

2017-07-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 14 July 2017 at 00:40:38 UTC, FoxyBrown wrote: Anyone have an efficient implementation that is easy to use? If you are OK with just a range spanning the two or more strings, then you could use chain as is.

nogc string concatenation?

2017-07-13 Thread FoxyBrown via Digitalmars-d-learn
Anyone have an efficient implementation that is easy to use?

Re: What is the simplest way of doing @nogc string concatenation?

2016-11-04 Thread Guillaume Piolat via Digitalmars-d-learn
On Friday, 4 November 2016 at 14:55:27 UTC, Guillaume Piolat wrote: On Thursday, 3 November 2016 at 18:54:14 UTC, Gary Willoughby wrote: What is the simplest way of doing @nogc string concatenation? I use sprintf + zero-terminated strings (or a RAII struct to convert slices to ZT strings

Re: What is the simplest way of doing @nogc string concatenation?

2016-11-04 Thread Guillaume Piolat via Digitalmars-d-learn
On Thursday, 3 November 2016 at 18:54:14 UTC, Gary Willoughby wrote: What is the simplest way of doing @nogc string concatenation? I use sprintf + zero-terminated strings (or a RAII struct to convert slices to ZT strings).

Re: What is the simplest way of doing @nogc string concatenation?

2016-11-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/3/16 2:54 PM, Gary Willoughby wrote: What is the simplest way of doing @nogc string concatenation? Where does it go? For instance, this should work: auto newstr = "hello, ".chain("world"); -Steve

Re: What is the simplest way of doing @nogc string concatenation?

2016-11-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 03, 2016 18:54:14 Gary Willoughby via Digitalmars-d- learn wrote: > What is the simplest way of doing @nogc string concatenation? std.range.chain is the closest that you're going to get with actual strings. Dynamic arrays require the GC to do concatenation, because they h

What is the simplest way of doing @nogc string concatenation?

2016-11-03 Thread Gary Willoughby via Digitalmars-d-learn
What is the simplest way of doing @nogc string concatenation?

Re: Compile time strings auto concatenation!?

2015-11-21 Thread Marc Schütz via Digitalmars-d-learn
On Friday, 20 November 2015 at 20:39:58 UTC, Ilya wrote: Can DMD frontend optimize string concatenation ``` enum Double(S) = S ~ S; assert(condition, "Text " ~ Double!"+" ~ ___FUNCTION__); ``` to ``` assert(condition, "Text ++_function_name_"); ``` ?

Re: Compile time strings auto concatenation!?

2015-11-21 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 20 November 2015 at 20:39:58 UTC, Ilya wrote: Can DMD frontend optimize string concatenation ``` enum Double(S) = S ~ S; assert(condition, "Text " ~ Double!"+" ~ ___FUNCTION__); ``` to ``` assert(condition, "Text ++_function_name_"); ``` ? I

Compile time strings auto concatenation!?

2015-11-20 Thread Ilya via Digitalmars-d-learn
Can DMD frontend optimize string concatenation ``` enum Double(S) = S ~ S; assert(condition, "Text " ~ Double!"+" ~ ___FUNCTION__); ``` to ``` assert(condition, "Text ++_function_name_"); ``` ?

Re: Compile time strings auto concatenation!?

2015-11-20 Thread Justin Whear via Digitalmars-d-learn
On Fri, 20 Nov 2015 20:39:57 +, Ilya wrote: > Can DMD frontend optimize > string concatenation > ``` > enum Double(S) = S ~ S; > > assert(condition, "Text " ~ Double!"+" ~ ___FUNCTION__); > ``` > > to > > ``` > assert(condition,

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-06 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 05:38:36 UTC, Jonathan M Davis wrote: Your suggestion only works by assuming that the result will fit in a char, which doesn't fit at all with how coversions are currently done in D. It would allow for narrowing conversions which lost data. And there's no way that

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-06 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 6 October 2015 at 09:28:29 UTC, Marc Schütz wrote: I see, this is a new problem introduced by `char + int = char`. But at least the following could be disallowed without introducing problems: int a = 'a'; char b = 32; But strictly speaking, we already accept overflow

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 06, 2015 09:28:27 Marc Schütz via Digitalmars-d-learn wrote: > I see, this is a new problem introduced by `char + int = char`. > But at least the following could be disallowed without > introducing problems: > > int a = 'a'; > char b = 32; Sure, it would be nice, but

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 05, 2015 11:48:51 Marc Schütz via Digitalmars-d-learn wrote: > On Monday, 5 October 2015 at 10:30:02 UTC, Jonathan M Davis wrote: > > On Monday, October 05, 2015 09:07:34 Marc Schütz via > > Digitalmars-d-learn wrote: > >> I don't think math would be a problem. There are some

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-05 Thread skilion via Digitalmars-d-learn
On Sunday, 4 October 2015 at 21:57:44 UTC, Jonathan M Davis wrote: When appending, b to a, the elements in b are being copied onto the end of a, and presumably it works in this case, because a ubyte is implicitly convertible to char. But all it's doing is converting the individual elements.

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-05 Thread Marc Schütz via Digitalmars-d-learn
On Sunday, 4 October 2015 at 21:57:44 UTC, Jonathan M Davis wrote: On Sunday, October 04, 2015 16:13:47 skilion via Digitalmars-d-learn wrote: Is this allowed by the language or it is a compiler bug ? void main() { char[] a = "abc".dup; ubyte[] b = [1, 2, 3]; a = b; // cannot

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 05, 2015 09:07:34 Marc Schütz via Digitalmars-d-learn wrote: > On Sunday, 4 October 2015 at 21:57:44 UTC, Jonathan M Davis wrote: > > On Sunday, October 04, 2015 16:13:47 skilion via > > Digitalmars-d-learn wrote: > >> Is this allowed by the language or it is a compiler bug ? >

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-05 Thread Marc Schütz via Digitalmars-d-learn
On Monday, 5 October 2015 at 10:30:02 UTC, Jonathan M Davis wrote: On Monday, October 05, 2015 09:07:34 Marc Schütz via Digitalmars-d-learn wrote: I don't think math would be a problem. There are some obvious rules that would likely just work with most existing code: char + int = char char -

Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-04 Thread skilion via Digitalmars-d-learn
Is this allowed by the language or it is a compiler bug ? void main() { char[] a = "abc".dup; ubyte[] b = [1, 2, 3]; a = b; // cannot implicitly convert expression (b) of type ubyte[] to char[] a ~= b; // works }

Re: Concatenation of ubyte[] to char[] works, but assignation doesn't

2015-10-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 04, 2015 16:13:47 skilion via Digitalmars-d-learn wrote: > Is this allowed by the language or it is a compiler bug ? > > void main() { > char[] a = "abc".dup; > ubyte[] b = [1, 2, 3]; > a = b; // cannot implicitly convert expression (b) of type > ubyte[] to char[]

Re: string concatenation with %s

2015-03-30 Thread anonymous via Digitalmars-d-learn
On Monday, 30 March 2015 at 17:18:01 UTC, Suliman wrote: same problem. I am preparing string to next SQL request: string sss = format(SELECT * FROM test.imgs WHERE src LIKE CONCAT('%', REPLACE(CAST(CURDATE()as char), -, ), '%') OR CONCAT('%', CAST(CURDATE()as char), '%')); Here's your code

Re: string concatenation with %s

2015-03-30 Thread Suliman via Digitalmars-d-learn
string sss = format(foo-, bar); It should be obvious now that you forgot to escape those double quotes. Thanks! Is there any way to stay string as is. without need of it's escaping and so on? It's seems I have seen something like it in docs, but I am not sure about it...

Re: string concatenation with %s

2015-03-30 Thread anonymous via Digitalmars-d-learn
On Monday, 30 March 2015 at 17:34:20 UTC, Suliman wrote: string sss = format(foo-, bar); It should be obvious now that you forgot to escape those double quotes. Thanks! Is there any way to stay string as is. without need of it's escaping and so on? It's seems I have seen something like it

Re: string concatenation with %s

2015-03-30 Thread Suliman via Digitalmars-d-learn
same problem. I am preparing string to next SQL request: string sss = format(SELECT * FROM test.imgs WHERE src LIKE CONCAT('%', REPLACE(CAST(CURDATE()as char), -, ), '%') OR CONCAT('%', CAST(CURDATE()as char), '%')); but I am getting next error: source\app.d(178): Error: invalid array

Re: Difference between concatenation and appendation

2015-01-25 Thread WhatMeWorry via Digitalmars-d-learn
On Monday, 26 January 2015 at 01:57:04 UTC, bearophile wrote: Laeeth Isharc: I think concatenation and append are used as synonyms (the same meaning is meant). a~=b or a=a~b a=a~b always allocates a new array, while a~=b sometimes re-allocates in place. Bye, bearophile Perfect! Thank

Re: Difference between concatenation and appendation

2015-01-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 26, 2015 01:17:15 WhatMeWorry via Digitalmars-d-learn wrote: Ok, I just made up that word. But what is the difference between appending and concatenating? Page 100 of TPDL says The result of the concatenation is a new array... and the section on appending talks about

Re: Difference between concatenation and appendation

2015-01-25 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 26 January 2015 at 01:17:17 UTC, WhatMeWorry wrote: Ok, I just made up that word. But what is the difference between appending and concatenating? Page 100 of TPDL says The result of the concatenation is a new array... and the section on appending talks about possibly needing

Re: Difference between concatenation and appendation

2015-01-25 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 26 January 2015 at 01:57:04 UTC, bearophile wrote: Laeeth Isharc: I think concatenation and append are used as synonyms (the same meaning is meant). a~=b or a=a~b a=a~b always allocates a new array, while a~=b sometimes re-allocates in place. Bye, bearophile Thanks

Difference between concatenation and appendation

2015-01-25 Thread WhatMeWorry via Digitalmars-d-learn
Ok, I just made up that word. But what is the difference between appending and concatenating? Page 100 of TPDL says The result of the concatenation is a new array... and the section on appending talks about possibly needing expansion and reallocation of memory. But I still don't feel like I

Re: Difference between concatenation and appendation

2015-01-25 Thread 岩倉 澪
On Monday, 26 January 2015 at 01:17:17 UTC, WhatMeWorry wrote: Ok, I just made up that word. But what is the difference between appending and concatenating? Page 100 of TPDL says The result of the concatenation is a new array... and the section on appending talks about possibly needing

Re: Difference between concatenation and appendation

2015-01-25 Thread bearophile via Digitalmars-d-learn
Laeeth Isharc: I think concatenation and append are used as synonyms (the same meaning is meant). a~=b or a=a~b a=a~b always allocates a new array, while a~=b sometimes re-allocates in place. Bye, bearophile

Re: string concatenation with %s

2015-01-07 Thread Justin Whear via Digitalmars-d-learn
On Wed, 07 Jan 2015 16:38:23 +, Suliman wrote: I except that writefln have some behavior as string concatenation, but it does not. IS there any way to put needed values in place of %s in string? std.string.format interpolates string with the same behavior as writefln but returns

Re: string concatenation with %s

2015-01-07 Thread Gary Willoughby via Digitalmars-d-learn
', '%s');, date[i], a_fredericksburg[i], fredericksburg[i], a_college[i], college[i], a_planetary[i], planetary[i]); I except that writefln have some behavior as string concatenation, but it does not. IS there any way to put needed values in place of %s in string? Just FYI use prepared

string concatenation with %s

2015-01-07 Thread Suliman via Digitalmars-d-learn
], a_college[i], college[i], a_planetary[i], planetary[i]); I except that writefln have some behavior as string concatenation, but it does not. IS there any way to put needed values in place of %s in string?

Re: string concatenation with %s

2015-01-07 Thread bearophile via Digitalmars-d-learn
], fredericksburg[i], a_college[i], college[i], a_planetary[i], planetary[i]); I except that writefln have some behavior as string concatenation, but it does not. IS there any way to put needed values in place of %s in string? Please show the _clean_ input, followed by an output example. Bye

Re: string concatenation with %s

2015-01-07 Thread Suliman via Digitalmars-d-learn
Please show the _clean_ input, followed by an output example. Bye, bearophile to prevent visual corruption I had past it here: http://www.everfall.com/paste/id.php?ftzy9lxr6yfy Just FYI use prepared statements instead of string concatenation for SQL queries. You mean some tools

Re: string concatenation with %s

2015-01-07 Thread Suliman via Digitalmars-d-learn
std.string.format interpolates string with the same behavior as writefln Thanks!

Re: string concatenation with %s

2015-01-07 Thread novice2 via Digitalmars-d-learn
what if a_college[i] will contain ` char? almost SQL have prepare statement...

Re: Ropes (concatenation trees) for strings in D ?

2014-08-18 Thread Justin Whear via Digitalmars-d-learn
On Thu, 14 Aug 2014 05:57:17 +, Carl Sturtivant wrote: This is the idea I mean. http://citeseer.ist.psu.edu/viewdoc/download? doi=10.1.1.14.9450rep=rep1type=pdf Here's a C++ implementation supported I think by gcc. http://www.sgi.com/tech/stl/Rope.html Is there a D implementation of a

Re: Ropes (concatenation trees) for strings in D ?

2014-08-16 Thread MrSmith via Digitalmars-d-learn
On Saturday, 16 August 2014 at 02:26:29 UTC, ketmar via Digitalmars-d-learn wrote: On Fri, 15 Aug 2014 19:04:10 -0700 Timothee Cour via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: sounds like my C library based on this article:

Re: Ropes (concatenation trees) for strings in D ?

2014-08-16 Thread ketmar via Digitalmars-d-learn
On Sat, 16 Aug 2014 10:25:01 + MrSmith via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Can you also share your progress? sure. the project has no public repo yet, but you can take a look at it's current state here: http://ketmar.no-ip.org/etx.txz no undo/redo support for

Re: Ropes (concatenation trees) for strings in D ?

2014-08-16 Thread ketmar via Digitalmars-d-learn
On Sat, 16 Aug 2014 10:25:01 + MrSmith via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Can you also share your progress? here is public repo: http://repo.or.cz/w/etx.d.git remember, this is not even alpha-quality code (but it seems to be stable enough to build something upon

Re: Ropes (concatenation trees) for strings in D ?

2014-08-15 Thread Kagamin via Digitalmars-d-learn
Search gave result enough rope to hang yourself.

Re: Ropes (concatenation trees) for strings in D ?

2014-08-15 Thread ketmar via Digitalmars-d-learn
On Fri, 15 Aug 2014 19:04:10 -0700 Timothee Cour via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: sounds like my C library based on this article: http://e98cuenc.free.fr/wordprocessor/piecetable.html i'm slowly converting my C code to D (nothing fancy yet, still C-style). it's

Re: InputRange Concatenation

2013-11-23 Thread Adam D. Ruppe
On Saturday, 23 November 2013 at 23:39:12 UTC, Nordlöw wrote: Is there a higher-order range pattern that concatenate two InputRanges? Sounds like you need std.range.chain: http://dlang.org/phobos/std_range.html#chain

Re: Efficient string concatenation?

2013-11-16 Thread JR
On Friday, 15 November 2013 at 22:33:34 UTC, Brad Anderson wrote: Appender in std.array is probably what you are looking for. std.algorithm.joiner is also useful (no allocations at all even) but the use case is a bit different. Is Appender considered up to Phobos' current standards? I

Re: Efficient string concatenation?

2013-11-16 Thread ilya-stromberg
On Friday, 15 November 2013 at 23:51:42 UTC, Jacek Furmankiewicz wrote: Thanks for the book! I printed it, all 673 pages of it. Immense work you have there. I think it's good to listen a little critics from newcomers. I belive that it helps Ali Cehreli to improve the book. Also, you can use

Re: Efficient string concatenation?

2013-11-16 Thread Ali Çehreli
On 11/16/2013 08:59 AM, ilya-stromberg wrote: I think it's good to listen a little critics from newcomers. I belive that it helps Ali Cehreli to improve the book. Exactly! :) Two quotes from the Introduction chapter: If you come across chapters that you find to be particularly difficult, it

Efficient string concatenation?

2013-11-15 Thread Jacek Furmankiewicz
Since D strings are immutable (like in most other languages), string concatenation is usually pretty inefficient due to the need to create a new copy of the string every time. I presume string concatenation using the typical array syntax can be optimized by the compiler to do all

Re: Efficient string concatenation?

2013-11-15 Thread Brad Anderson
On Friday, 15 November 2013 at 22:26:20 UTC, Jacek Furmankiewicz wrote: Since D strings are immutable (like in most other languages), string concatenation is usually pretty inefficient due to the need to create a new copy of the string every time. I presume string concatenation using

Re: Efficient string concatenation?

2013-11-15 Thread Justin Whear
On Fri, 15 Nov 2013 23:26:19 +0100, Jacek Furmankiewicz wrote: Since D strings are immutable (like in most other languages), string concatenation is usually pretty inefficient due to the need to create a new copy of the string every time. I presume string concatenation using the typical

Re: Efficient string concatenation?

2013-11-15 Thread Justin Whear
On Fri, 15 Nov 2013 22:30:35 +, Justin Whear wrote: std.array has an Appender type that can be used to build up a string (or any other array type) efficiently. Oh, and if you have an idea of how large the result might grow, be sure to use the reserve() method on the appender.

Re: Efficient string concatenation?

2013-11-15 Thread Jacek Furmankiewicz
Thank you all. I am learning D by going through Ali Cehreli's otherwise excellent Programming in D PDF and he did not show this in his initial chapter on Strings.

Re: Efficient string concatenation?

2013-11-15 Thread qznc
On Friday, 15 November 2013 at 22:35:48 UTC, Jacek Furmankiewicz wrote: I am learning D by going through Ali Cehreli's otherwise excellent Programming in D PDF and he did not show this in his initial chapter on Strings. Well, Appender is not string specific. D feels like being in a different

Re: Efficient string concatenation?

2013-11-15 Thread Ali Çehreli
On 11/15/2013 02:35 PM, Jacek Furmankiewicz wrote: Programming in D PDF and he did not show this in his initial chapter on Strings. Sorry about that. :) As I was targeting novices to programming, I tried to give as much as needed but as little as possible, so that the reader would not be

Re: Efficient string concatenation?

2013-11-15 Thread Jacek Furmankiewicz
Thanks for the book! I printed it, all 673 pages of it. Immense work you have there.

Tips for fast string concatenation?

2013-06-21 Thread Gary Willoughby
Have you any tips for using D when you need fast string concatenation? I regularly use code like this: foreach (i, range) { foo ~= bar; } or: foo = foo ~ bar ~ baz ~ qux; I've used std.string.format(...) in some instances which sped things up which surprised me

Re: Tips for fast string concatenation?

2013-06-21 Thread Vladimir Panteleev
On Friday, 21 June 2013 at 10:09:10 UTC, Gary Willoughby wrote: Are there faster ways of appending strings? You'll want to use appender, from std.array: http://dlang.org/phobos/std_array.html#.Appender

Re: Tips for fast string concatenation?

2013-06-21 Thread Jonathan M Davis
On Friday, June 21, 2013 12:09:09 Gary Willoughby wrote: Have you any tips for using D when you need fast string concatenation? I regularly use code like this: foreach (i, range) { foo ~= bar; } or: foo = foo ~ bar ~ baz ~ qux; I've used

Re: Tips for fast string concatenation?

2013-06-21 Thread monarch_dodra
On Friday, 21 June 2013 at 10:09:10 UTC, Gary Willoughby wrote: Have you any tips for using D when you need fast string concatenation? I regularly use code like this: foreach (i, range) { foo ~= bar; } or: foo = foo ~ bar ~ baz ~ qux; I've used std.string.format

Re: Tips for fast string concatenation?

2013-06-21 Thread John Colvin
On Friday, 21 June 2013 at 11:33:29 UTC, monarch_dodra wrote: On Friday, 21 June 2013 at 10:09:10 UTC, Gary Willoughby wrote: Have you any tips for using D when you need fast string concatenation? I regularly use code like this: foreach (i, range) { foo ~= bar; } or: foo

  1   2   >