On Sunday, 13 November 2022 at 17:10:23 UTC, DLearner wrote:
...
The slight generalisation shown at bottom also worked.
However, is there a way of avoiding the for-loop?
...
I don't have too much knowledge in D, but I think so. (My main
language is C).
Well, one way to make things "better"
On Sunday, 13 November 2022 at 16:11:17 UTC, matheus. wrote:
[...]
You should add the code below after "auto B = A.dup;":
B[0].Txt = A[0].Txt.dup;
The "Txt" property inside B is still referencing A without the
above.
Matheus.
Thank you - your suggestion worked.
The slight
On Sunday, 13 November 2022 at 15:45:40 UTC, DLearner wrote:
```D
struct test_struct {
char[] Txt;
}
test_struct[] A;
auto B = A.dup;
```
But A is not an `int[]` in your new example. You need a "deep
copy" and I can see that similar questions had been asked in this
forum
On Sunday, 13 November 2022 at 15:45:40 UTC, DLearner wrote:
On Sunday, 13 November 2022 at 14:39:26 UTC, Siarhei Siamashka
wrote:
On Sunday, 13 November 2022 at 14:28:45 UTC, DLearner wrote:
Creating a step 1.5:
```
int[] B = A;
```
```D
auto B = A.dup;
```
This will create a copy of A
On Sunday, 13 November 2022 at 14:39:26 UTC, Siarhei Siamashka
wrote:
On Sunday, 13 November 2022 at 14:28:45 UTC, DLearner wrote:
Creating a step 1.5:
```
int[] B = A;
```
```D
auto B = A.dup;
```
This will create a copy of A rather than referencing to the
same buffer in memory.
Tested:
On Sunday, 13 November 2022 at 14:28:45 UTC, DLearner wrote:
Creating a step 1.5:
```
int[] B = A;
```
```D
auto B = A.dup;
```
This will create a copy of A rather than referencing to the same
buffer in memory.
Hi
Program has two steps:
1. Creates an array (int[] A), whose size and element values are
only known at run-time.
Then:
2. The elements (but not the array size) are further processed in
a way that may or may not alter their value.
Requirement: to identify the indices (if any) of the