On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote:
question in the header, code in the body, execute on a X86 or
X86_64 CPU
```d
module test;
void setIt(ref bool b) @safe
{
b = false;
}
void main(string[] args)
{
ushort a = 0b;
bool* b = cast(bool*)&a;
s
On Monday, 15 July 2024 at 19:40:01 UTC, mw wrote:
On Friday, 12 July 2024 at 18:07:50 UTC, mw wrote:
[...]
FYI, now merged into the main branch:
https://github.com/py2many/py2many/tree/main/pyd
This is great and certainly deserves an own discussion
contribution in General.
Did you try t
I want to make a custom dictionary that I may iterate through
with foreach. Several times.
What I observe so far is that my dict as a simple forward range
is exhausted after the first foreach and I have to deeply copy it
beforehand.
With a simple associative array the exhaustion is not observed
Hello @monkyyy,
thank you for your help. I will study and try your code.
Meanwhile I have found that I can add this function into the
struct:
```d
// postblit constructor, see
//
https://stackoverflow.com/questions/38785624/d-struct-copy-constructor
this(this) {
stri
@Monkyyy: I adopted your solution, it is perfect.
I only have one problem left:
The foreach loop with associative arrays has two cases:
`foreach(key, val; arr)` and `foreach(x; arr)`.
In the second case only the values are iterated.
With the present solution the iteration delivers (key, val)
t
On Friday, 15 March 2024 at 17:15:56 UTC, monkyyy wrote:
On Friday, 15 March 2024 at 09:03:25 UTC, rkompass wrote:
@Monkyyy: I adopted your solution, it is perfect.
I only have one problem left:
The foreach loop with associative arrays has two cases:
`foreach(key, val; arr)` and `foreach(x; a
To solve the problem with the 1-variable and 2-variable versions
of foreach I
tried opApply and found that the compiler prefers it over opSlice
and opIndex() (the latter without argument).
My code:
```d
int opApply(int delegate(Variant) foreachblock) const {
int result
@bachmeier
You're not the first one. There's no technical reason for the
restriction. It's simply a matter of being opposed by those who
make these decisions on the basis that it's the wrong way to
program or something like that. Here is a recent thread:
https://forum.dlang.org/post/ikwphfwevg
The term containing the `pow` invocation computes the
alternating sequence -1, 1, -1, ..., which can be replaced by
e.g.
```
immutable int [2] sign = [-1, 1];
n += sign [i & 1] / (i * 2.0 - 1.0);
```
This saves the expensive call to the pow function.
I used the loop:
```d
for (
On Sunday, 24 March 2024 at 23:02:19 UTC, Sergey wrote:
On Sunday, 24 March 2024 at 22:16:06 UTC, rkompass wrote:
Are there some simple switches / settings to get a smaller
binary?
1) If possible you can use "betterC" - to disable runtime
2) otherwise
```bash
--release --O3 --flto=full -fvisib
I apologize for digressing a little bit further - just to share
insights to other learners.
I had the question, why my binary was so big (> 4M), discovered
the
`gdc -Wall -O2 -frelease -shared-libphobos` options (now >200K).
Then I tried to avoid GC, just learnt about this: The GC in the
Leib
On Wednesday, 27 March 2024 at 13:38:29 UTC, Salih Dincer wrote:
So, not works this:
```d
fib(1, 1).take(48)
//.array
.chunks(2)
.map!"a[1] / a[0]"
.back
.writeln; // 1.61803
```
Thanks...
SDB@79
This works:
```d
import std.stdio;
import std.ran
On Thursday, 28 March 2024 at 01:09:34 UTC, Salih Dincer wrote:
Good thing you're digressing; I am 45 years old and I still
cannot say that I am finished as a student! For me this is
version 4 and it looks like we don't need a 3rd variable other
than the function parameter and return value:
On Thursday, 28 March 2024 at 14:07:43 UTC, Salih Dincer wrote:
On Thursday, 28 March 2024 at 11:50:38 UTC, rkompass wrote:
Turning back to this: Are there similarly simple libraries for
C, that allow for
parallel computation?
You can achieve parallelism in C using libraries such as
OpenMP
On Thursday, 28 March 2024 at 03:54:05 UTC, Salih Dincer wrote:
On Wednesday, 27 March 2024 at 20:50:05 UTC, rkompass wrote:
This works:
I decided to give the full code. Maybe then it will be better
understood what I mean. I actually pointed out the indirect
solution above but it's a bit ugl
On Friday, 5 April 2024 at 16:05:20 UTC, H. S. Teoh wrote:
On Fri, Apr 05, 2024 at 03:18:09PM +, Salih Dincer via
Digitalmars-d-learn wrote:
Hi everyone,
Technically r1 and r2 are different types of range. Isn't it
inconsistent to chain both? If not, why is the char type
converted to int?
On Friday, 5 April 2024 at 21:26:10 UTC, Salih Dincer wrote:
On Friday, 5 April 2024 at 21:16:42 UTC, rkompass wrote:
In the first example the int's are converted to doubles (also
common type).
But they appear as int's because writeln does not write a
trailing .0.
But it doesn't work as you
On Sunday, 16 February 2025 at 18:46:56 UTC, Ian wrote:
Hi,
I'm looking at the double linked list in std.containers and it
says that insertion in front or back are O(log n). How come
they are not O(1) ?
https://dlang.org/phobos/std_container_dlist.html#.DList.insertFront
Also, is this quest
18 matches
Mail list logo