On Mon, Oct 03, 2022 at 05:38:25PM -0700, Ali Çehreli via Digitalmars-d-learn
wrote:
[...]
> Good catch but I think what we want is a copy of the front element, at
> least for InputRanges (.save does not work for File.byLine :/).
One of the things we need to settle in Phobos v2 is what to do
On Tuesday, 4 October 2022 at 00:38:25 UTC, Ali Çehreli wrote:
Good catch but I think what we want is a copy of the front
element, at least for InputRanges (.save does not work for
File.byLine :/).
What is the generic way of copying an element? I wonder whether
we have to use isSomeString to
On 10/3/22 23:06, Ali Çehreli via Digitalmars-d-learn wrote:
auto rotatedView(R)(R range)
Or even more generic by chaining two slices in case the range permits it:
auto rotatedView(R)(R range, long n = 1)
if (...)
{
if (n == 0) return range;
...
n %= range.length;
On 10/3/22 17:00, Paul Backus wrote:
> On Monday, 3 October 2022 at 21:06:36 UTC, Ali Çehreli wrote:
>> On 10/3/22 13:48, Andrey Zherikov wrote:
>>> a "rotated view".
>>
>> Without indexes:
>>
>> import std.range : empty;
>>
>> auto rotatedView(R)(R range)
>> in (!range.empty)
>> {
>> import
On Monday, 3 October 2022 at 21:06:36 UTC, Ali Çehreli wrote:
On 10/3/22 13:48, Andrey Zherikov wrote:
a "rotated view".
Without indexes:
import std.range : empty;
auto rotatedView(R)(R range)
in (!range.empty)
{
import std.range : chain, front, only, popFront;
const fr =
On 10/3/22 13:48, Andrey Zherikov wrote:
a "rotated view".
Without indexes:
import std.range : empty;
auto rotatedView(R)(R range)
in (!range.empty)
{
import std.range : chain, front, only, popFront;
const fr = range.front;
range.popFront();
return chain(range, only(fr));
}
On Monday, 3 October 2022 at 18:09:05 UTC, Fausto wrote:
Hello all,
I am trying to rotate left an array.
I found a very basic way, and I am not sure if there is
something clever than this :) maybe using slices...
the external for represents how many times you are rotating (in
this case 2).
On Monday, 3 October 2022 at 18:02:51 UTC, Salih Dincer wrote:
On Sunday, 2 October 2022 at 19:48:52 UTC, mw wrote:
```
text.csvReader!Layout(["b","c","a"]); // Read only
these column
```
The intention is very clear: only read the selected columns
from the csv, and for any other
On Monday, 3 October 2022 at 18:09:05 UTC, Fausto wrote:
Hello all,
I am trying to rotate left an array.
I found a very basic way, and I am not sure if there is
something clever than this :) maybe using slices...
Here we can't use slice assignment instead of the inner loop
because that
Hello all,
I am trying to rotate left an array.
I found a very basic way, and I am not sure if there is something
clever than this :) maybe using slices...
the external for represents how many times you are rotating (in
this case 2).
```d
void main()
{
import std.range;
import
On Sunday, 2 October 2022 at 19:48:52 UTC, mw wrote:
```
text.csvReader!Layout(["b","c","a"]); // Read only
these column
```
The intention is very clear: only read the selected columns
from the csv, and for any other fields of class Layout, just
ignore (with the default D .init
On Monday, 3 October 2022 at 14:37:35 UTC, kdevel wrote:
On Sunday, 2 October 2022 at 23:37:26 UTC, ryuukk_ wrote:
I got the answer thanks to IRC chat:
https://dlang.org/spec/declaration.html#void_init
Quote:
Implementation Defined: If a void initialized variable's
value is used
On Monday, 3 October 2022 at 10:13:09 UTC, Rene Zwanenburg wrote:
On Monday, 3 October 2022 at 08:10:43 UTC, Bienlein wrote:
My question is whether someone has an idea for a better
solution.
You can pass a lambda to the fiber constructor. For example:
```
void fiberFunc(int i)
{
On Sunday, 2 October 2022 at 23:37:26 UTC, ryuukk_ wrote:
I got the answer thanks to IRC chat:
https://dlang.org/spec/declaration.html#void_init
Quote:
Implementation Defined: If a void initialized variable's value
is used
before it is set, its value is implementation defined.
On Sunday, 2 October 2022 at 21:18:43 UTC, mw wrote:
[snipping]
A CSV library should consider all the use cases, and allow
users to ignore certain fields.
In R, you have to force `NULL` for `colClasses` for the other
columns. In other words, the user has to know the number of
columns of
On Monday, 3 October 2022 at 08:10:43 UTC, Bienlein wrote:
Hello,
I'm looking for a way to pass parameters to a function called
by a fiber. Starting a fiber works like this:
You can also make a subclass of fiber that stores them with the
object.
On 10/2/22 12:21 PM, data pulverizer wrote:
I've noticed that `writeln` calls the destructor of a struct multiple
times and would like to know how to stop this from happening. It has
become a very serious problem when working with objects that have memory
management external to D.
I know you
On Monday, 3 October 2022 at 08:10:43 UTC, Bienlein wrote:
In the code above there is no way to add parameters to myFunc.
The construcor of class Fiber does not allow for a function to
be passed that has parameters (unlike for the spawn function
when starting a thread).
You try
On 10/3/22 09:35, tsbockman wrote:
On Sunday, 2 October 2022 at 23:45:45 UTC, drug007 wrote:
It works but not as someone could expect. In case of
```D
Foo[2] arr = void;
```
`arr` value is not defined, it is not an initialized array of
uninitialized elements like you want, it is just
On Monday, 3 October 2022 at 08:10:43 UTC, Bienlein wrote:
My question is whether someone has an idea for a better
solution.
You can pass a lambda to the fiber constructor. For example:
```
void fiberFunc(int i)
{
writeln(i);
}
void main()
{
auto fiber = new Fiber(() =>
Hello,
I'm looking for a way to pass parameters to a function called by
a fiber. Starting a fiber works like this:
int main()
{
auto fiber = new Fiber();
fiber.call();
fiber.call();
return 0;
}
void myFunc() {
writeln("Fiber called");
Fiber.yield();
writeln("Fiber
On 02/10/2022 13:00, Daniel Donnell wrote:
Visual D doesn't work - it just ate my app.obj file and can't find it
anymore no matter if I clean or re-order the executable paths in
settings.
Can you be more specific what you are doing and what is going wrong?
On 02/10/2022 23:28, rikki
On Monday, 3 October 2022 at 07:45:47 UTC, Chris Katko wrote:
I know there's gotta be some simple one liner function in D,
but I can't think of it.
I don't know if you're looking for type safety, but you can just
do `cast(float*) values.ptr;` or `cast(float[]) values[]`.
```D
struct pair
{
float x;
float y;
}
pair[10] values;
import std.conv;
auto valuesInCStyle = to!(const float*)(values);
```
Now that's not going to work because (I would imagine) to!
doesn't understand x, and y, can be placed in order to give an
array of:
valuesInCStyle =
On Sunday, 2 October 2022 at 23:30:16 UTC, ryuukk_ wrote:
```D
MyStruct test = void;
```
Does this guarantee that the compiler will not initialize it?
It's more of a request, than a guarantee. For example, `= void`
may be ignored for the fields of `struct`s and `class`es:
```D
struct ABC {
On Sunday, 2 October 2022 at 23:45:45 UTC, drug007 wrote:
It works but not as someone could expect. In case of
```D
Foo[2] arr = void;
```
`arr` value is not defined, it is not an initialized array of
uninitialized elements like you want, it is just uninitialized
array.
This is incorrect. It
26 matches
Mail list logo