I was following the documentation here:
http://dlang.org.mirror/spec/arrays.html#slicing and I'm having a
problem comparing the returned Slice from a function with an
array.
Here's the simplified code:
```
import std.stdio;
import std.regex;
import std.string;
import std.array;
auto sliceIt(
On Tuesday, 11 June 2024 at 08:29:06 UTC, madwebness wrote:
unittest {
auto words = ["HELLO", "world", "hi", "ENDOFTHERUNWAY"];
auto resulting_arr = sliceIt(["world", "hi"]);
assert(resulting_arr == ["world", "hi"]);
}
Correction here, I, of course, meant:
```
auto resulting_arr = slice
There are two more corrections to make.
Both in sliceIt.
Note: array is a function not a type and is for ranges, slices are built
in language concept. Associate Arrays (map) use the syntax ``Type[Type]``.
On Tuesday, 11 June 2024 at 08:44:25 UTC, Richard (Rikki) Andrew
Cattermole wrote:
There are two more corrections to make.
Both in sliceIt.
Note: array is a function not a type and is for ranges, slices
are built in language concept. Associate Arrays (map) use the
syntax ``Type[Type]``.
Whi
On 11/06/2024 9:17 PM, madwebness wrote:
On Tuesday, 11 June 2024 at 08:44:25 UTC, Richard (Rikki) Andrew
Cattermole wrote:
There are two more corrections to make.
Both in sliceIt.
Note: array is a function not a type and is for ranges, slices are
built in language concept. Associate Arrays
On Tuesday, 11 June 2024 at 09:17:21 UTC, madwebness wrote:
While I do understand what you're saying, I'm not sure I
understand how to fix the code.
With the following function definition what the function returns
is correct and the problem is in the unittest code. Note that
`writeln()` print
On Tuesday, 11 June 2024 at 09:29:05 UTC, madwebness wrote:
My version that runs:
Ran the code exactly as you posted. It works and I found the
issue. Apparently, if I add =* to the end of the last element,
the assertion fails with the error.
```
auto words = ["HELLO", "world", "hi", "ENDOFT
On Tuesday, 11 June 2024 at 09:48:36 UTC, madwebness wrote:
On Tuesday, 11 June 2024 at 09:29:05 UTC, madwebness wrote:
My version that runs:
Ran the code exactly as you posted. It works and I found the
issue. Apparently, if I add =* to the end of the last element,
the assertion fails with t
On 11/06/2024 9:51 PM, madwebness wrote:
Ah, my mistake. With the regular expression adjusted to
`r"^[A-Z]+(=.*)?$"` it works just fine. Thank you very much for running
the code for me. All very simple, I'm just new to the language.
All good, happy to help!
We also have people on Discord and
On Tuesday, 11 June 2024 at 13:00:50 UTC, Vinod K Chandran wrote:
...
Similar posts that may help:
https://forum.dlang.org/thread/hryadrwplyezihwag...@forum.dlang.org
https://forum.dlang.org/thread/dblfikgnzqfmmglwd...@forum.dlang.org
Matheus.
On Tuesday, 11 June 2024 at 13:35:19 UTC, matheus wrote:
On Tuesday, 11 June 2024 at 13:00:50 UTC, Vinod K Chandran
wrote:
...
Similar posts that may help:
https://forum.dlang.org/thread/hryadrwplyezihwag...@forum.dlang.org
https://forum.dlang.org/thread/dblfikgnzqfmmglwd...@forum.dlang.org
1) arena allocator makes memory manageable with occasional cache
invalidation problem
2) no hashtable no problem
3) error handling depends on your code complexity, but even in
complex C# code I found exceptions as boolean: you either have an
exception or you don't
4) I occasionally use CTFE, w
On Tuesday, 11 June 2024 at 14:59:24 UTC, Kagamin wrote:
1) arena allocator makes memory manageable with occasional
cache invalidation problem
2) no hashtable no problem
3) error handling depends on your code complexity, but even in
complex C# code I found exceptions as boolean: you either have
On 11.06.2024 17:59, Kagamin wrote:
1) arena allocator makes memory manageable with occasional cache
invalidation problem
2) no hashtable no problem
[OT] could you elaborate what problems they cause?
3) error handling depends on your code complexity, but even in complex
C# code I found excep
Comparison between a Variant and an array is straightforward. How
does one accomplish the same between a SumType and an array?
```d
import std.variant;
import std.sumtype;
import std.stdio;
struct S
{
SumType!(double[]) data; // {1}
}
void main()
{
Variant v = [1.7, 2.7, 3.7, 4.7, 5.7
On Tuesday, 11 June 2024 at 13:00:50 UTC, Vinod K Chandran wrote:
Hi all,
I am planning to write some D code without GC. But I have no
prior experience with it. I have experience using manual memory
management languages. But D has so far been used with GC. So I
want to know what pitfalls it ha
On Tuesday, 11 June 2024 at 16:54:44 UTC, Steven Schveighoffer
wrote:
I would instead ask the reason for wanting to write D code
without the GC.
-Steve
Hi Steve,
Two reasons.
1. I am writting a dll to use in Python. So I am assuming that
manual memory management is better for this project
On Tuesday, 11 June 2024 at 16:41:46 UTC, confuzzled wrote:
Also, assuming that {1} read "SumType!(double)[] data;", what
would be the proper way to accomplish the assignment at {2} and
the subsequent comparison.
Not sure how to do solve the fist part of the question yet but I
was able to
On Tuesday, 11 June 2024 at 16:41:46 UTC, confuzzled wrote:
Comparison between a Variant and an array is straightforward.
How does one accomplish the same between a SumType and an array?
Okay, this is what I came up with. Just a sanity check please.
Did I do this correctly? Is there somethin
On Tuesday, 11 June 2024 at 18:26:50 UTC, confuzzled wrote:
On Tuesday, 11 June 2024 at 16:41:46 UTC, confuzzled wrote:
Comparison between a Variant and an array is straightforward.
How does one accomplish the same between a SumType and an
array?
Okay, this is what I came up with. Just a sa
On Tuesday, 11 June 2024 at 16:41:46 UTC, confuzzled wrote:
Comparison between a Variant and an array is straightforward.
How does one accomplish the same between a SumType and an array?
```d
import std.variant;
import std.sumtype;
import std.stdio;
struct S
{
SumType!(double[]) data; //
On Tuesday, 11 June 2024 at 22:54:50 UTC, Steven Schveighoffer
wrote:
Let's see how it works if you want to both check that the value
is a `double[]` and that it matches your value:
```d
SumType!(double[], int) s = [1.7, 2.7, 3.7, 4.7, 5.7];
assert(s.data.match!(
```
This should be `s.match
On Tuesday, 11 June 2024 at 17:15:07 UTC, Vinod K Chandran wrote:
On Tuesday, 11 June 2024 at 16:54:44 UTC, Steven Schveighoffer
wrote:
I would instead ask the reason for wanting to write D code
without the GC.
-Steve
Hi Steve,
Two reasons.
1. I am writting a dll to use in Python. So I am
23 matches
Mail list logo