On Saturday, 17 August 2024 at 05:28:37 UTC, Bruce wrote:
Example.
I want to find the index of an item in an array.
```
import std.stdio;
import std.string;
void main()
{
string text = "Hello, World!";
string searchSubstring = "World";
ptrdiff_t index = text.indexOf(searchSubstring);
On Saturday, 17 August 2024 at 06:11:58 UTC, Bruce wrote:
On Saturday, 17 August 2024 at 05:42:42 UTC, monkyyy wrote:
On Saturday, 17 August 2024 at 05:28:37 UTC, Bruce wrote:
It's the correct name for the wrong function
Are you saying this is wrong?
auto i = arr.countUntil("ha");
yes
```d
On Saturday, 17 August 2024 at 05:42:42 UTC, monkyyy wrote:
On Saturday, 17 August 2024 at 05:28:37 UTC, Bruce wrote:
It's the correct name for the wrong function
Are you saying this is wrong?
auto i = arr.countUntil("ha");
On Friday, 16 August 2024 at 11:37:08 UTC, Nick Treleaven wrote:
```d
// use a fixed array:
immutable char[60] a = '-';
string s = a.dup; // copy to heap, assuming you need the data
to escape (use a[] otherwise)
s.writeln();
This seems to work without having to make a string dup. I just
w
On Saturday, 17 August 2024 at 05:28:37 UTC, Bruce wrote:
This seems to work but now I'm concerned.
Why was it so hard to find?
What is the best way to search for a function
in the Phobos library?
It's the correct name for the wrong function
If you use it on unicode strings or filters it's ju
On Wednesday, 14 August 2024 at 07:48:58 UTC, Cecil Ward wrote:
Does D give any guarantees for performance order-something ?
What’s the current lib implementation like?
It is amortized O(1), like most hash implementations.
-Steve
On Friday, 16 August 2024 at 18:00:25 UTC, Renato Athaydes wrote:
On Friday, 16 August 2024 at 13:30:53 UTC, IchorDev wrote:
On Friday, 16 August 2024 at 11:37:08 UTC, Nick Treleaven
wrote:
On Friday, 16 August 2024 at 06:15:18 UTC, Bruce wrote:
```d
string s = a.dup; // copy to heap, assuming
On Friday, 16 August 2024 at 13:30:53 UTC, IchorDev wrote:
On Friday, 16 August 2024 at 11:37:08 UTC, Nick Treleaven wrote:
On Friday, 16 August 2024 at 06:15:18 UTC, Bruce wrote:
```d
string s = a.dup; // copy to heap, assuming you need the data
to escape (use a[] otherwise)
s.writeln();
```
On Friday, 16 August 2024 at 15:58:31 UTC, Nick Treleaven wrote:
On Friday, 16 August 2024 at 13:30:53 UTC, IchorDev wrote:
On Friday, 16 August 2024 at 11:37:08 UTC, Nick Treleaven
wrote:
On Friday, 16 August 2024 at 06:15:18 UTC, Bruce wrote:
```d
string s = a.dup; // copy to heap, assuming y
On Friday, August 16, 2024 10:37:45 AM MDT Nick Treleaven via Digitalmars-d-
learn wrote:
> On Friday, 16 August 2024 at 16:30:09 UTC, Jonathan M Davis wrote:
> > Whether the result of dup is then able to be implicitly
> > converted to immutable based on whether the operation is pure
> > depends on
On Friday, 16 August 2024 at 16:30:09 UTC, Jonathan M Davis wrote:
Well, you if you use dup, you're asking for a mutable array,
whereas if you use idup, you're asking for an immutable array.
Yes, `idup` may be needed e.g. for overloads varying on
mutability.
Whether the result of dup is then
On Friday, August 16, 2024 9:58:31 AM MDT Nick Treleaven via Digitalmars-d-
learn wrote:
> On Friday, 16 August 2024 at 13:30:53 UTC, IchorDev wrote:
> > On Friday, 16 August 2024 at 11:37:08 UTC, Nick Treleaven wrote:
> >> On Friday, 16 August 2024 at 06:15:18 UTC, Bruce wrote:
> >> ```d
> >> stri
On Friday, 16 August 2024 at 13:30:53 UTC, IchorDev wrote:
On Friday, 16 August 2024 at 11:37:08 UTC, Nick Treleaven wrote:
On Friday, 16 August 2024 at 06:15:18 UTC, Bruce wrote:
```d
string s = a.dup; // copy to heap, assuming you need the data
to escape (use a[] otherwise)
s.writeln();
```
On Friday, 16 August 2024 at 11:37:08 UTC, Nick Treleaven wrote:
On Friday, 16 August 2024 at 06:15:18 UTC, Bruce wrote:
```d
string s = a.dup; // copy to heap, assuming you need the data
to escape (use a[] otherwise)
s.writeln();
```
I think you meant `idup`? `dup` will make it mutable.
On Friday, 16 August 2024 at 06:15:18 UTC, Bruce wrote:
Is there an easy way to create a 60 character string in D?
Like in Python...
ul = '-'*60
2 ways:
```d
// use a fixed array:
immutable char[60] a = '-';
string s = a.dup; // copy to heap, assuming you need the data to
escape (use a[] othe
15 matches
Mail list logo