On Tuesday, 20 October 2020 at 16:58:12 UTC, Severin Teona wrote:
Hi guys.
I have a curiosity, regarding [1] - I had encountered some
"undefined reference" errors when trying to link the druntime
(compiled for an embedded architecture) without some
implementation of the POSIX thread calls (an
What is the simplest way to output every nth element of an array?
I can do it using a for loop:
void main()
{
int[5] a = [1,2,3,4,5];
for (int i = 0 ; i <= 4 ; i += 2)
{
writeln(a[i]);
}
}
Basically, I am wondering if I missed something.
There are two other way:
```D
import std;
void main()
{
int[] a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ];
// using foreach
foreach (i; 0..a.length)
write(a[i], ", ");
writeln;
// using stride
writeln(stride(a, 2));
}
```
On Wednesday, 21 October 2020 at 12:06:00 UTC, drug wrote:
There are two other way:
Thanks, drug.
stride was what I was looking for.
On Wednesday, 21 October 2020 at 11:55:54 UTC, DMon wrote:
What is the simplest way to output every nth element of an
array?
I can do it using a for loop:
void main()
{
int[5] a = [1,2,3,4,5];
for (int i = 0 ; i <= 4 ; i += 2)
{
writeln(a[i]);
}
}
Basically, I am wonde
On Wednesday, 21 October 2020 at 12:06:00 UTC, drug wrote:
There are two other way:
...
// using foreach
foreach (i; 0..a.length)
write(a[i], ", ");
...
Yes you can use foreach, but in this case will not act the way
the OP wanted. In his for loop example the "i" is incremented
On Wednesday, 21 October 2020 at 13:43:51 UTC, matheus wrote:
foreach (i,j;a){
if(i%2==0){ write(j, ", ");}
}
Thank you, matheus. for each on the list.
On Wednesday, 21 October 2020 at 13:04:40 UTC, Ferhat Kurtulmuş
wrote:
import std.range;
import std.stdio;
void main(){
auto source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
auto chunks = chunks(source, 2);
writeln(chunks[0]); // [1, 2]
foreach(c; chunks)
writeln(c[1]);
}
An
On Tuesday, 20 October 2020 at 16:58:12 UTC, Severin Teona wrote:
My curiosity is what would change if I removed from the
druntime everything that has to do with mutexes or threads.
Nothing if you don't plan to use multithreading.
I temporary disabled threading and appropriate unittests from
On Wednesday, 21 October 2020 at 16:04:20 UTC, Denis Feklushkin
wrote:
On Tuesday, 20 October 2020 at 16:58:12 UTC, Severin Teona
wrote:
My curiosity is what would change if I removed from the
druntime everything that has to do with mutexes
As I remember, your plan is to use some type of RTO
On Wednesday, 21 October 2020 at 14:03:54 UTC, DMon wrote:
On Wednesday, 21 October 2020 at 13:04:40 UTC, Ferhat Kurtulmuş
wrote:
import std.range;
import std.stdio;
void main(){
auto source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
auto chunks = chunks(source, 2);
writeln(chunks[0]); //
I ask this question because I chased a very very nasty bug all
the way down, and I think I found the offender:
I have a extern(C++) struct that contains an 8-byte integer
followed by a 4-byte enum value. I came across two variables of
that type, that are not equal by comparison (no opEquals
d
On Wednesday, 21 October 2020 at 19:23:43 UTC, Simon van Bernem
wrote:
The only explanation I can think of is that D memcmps the
entire struct including the padding. Is this correct?
If so, what can I do about this? Why doesn't the opEquals get
modified appropriately even though the struct is
When an assert fails in a unittest, I only get which line that
failed. However, it would be very useful to see what the values
are on either side of the unary boolean expression. Is this
possible?
On Wednesday, 21 October 2020 at 22:30:11 UTC, IGotD- wrote:
When an assert fails in a unittest, I only get which line that
failed. However, it would be very useful to see what the values
are on either side of the unary boolean expression. Is this
possible?
try compiling with dmd -checkaction
On Wednesday, 21 October 2020 at 16:38:34 UTC, Ferhat Kurtulmuş
wrote:
ş
UTF-8: ÅŸ
Numeric: ş
Ansi: ÅŸ
√
On Wednesday, 21 October 2020 at 22:41:42 UTC, Adam D. Ruppe
wrote:
try compiling with dmd -checkaction=context
Thanks, that was simple and it worked. Speaking of this,
shouldn't this be documented here for example.
https://dlang.org/spec/unittest.html
Just adding a friendly tip that -chec
Hi,
import std.stdio, std.conv;
void main(string[ ] args) {
auto a = (1).to!int; // this works
auto b = ("1").to!int; // this works
auto c = (1.1).to!int; // this works and c = 1
auto d = ("1.1").to!int; // Doesn't work
}
The forth line gives me:
std.conv.ConvException@/
On Wednesday, 21 October 2020 at 22:50:27 UTC, matheus wrote:
Since (1.1).to!int = 1, shouldn't the string value
("1.1").to!int at least try to convert to float/double and then
to int?
I don't think so. A silent string->double conversion isn't IMO
consistent with D's design.
"1.1".to!doubl
On Wednesday, 21 October 2020 at 22:48:04 UTC, IGotD- wrote:
On Wednesday, 21 October 2020 at 22:41:42 UTC, Adam D. Ruppe
wrote:
try compiling with dmd -checkaction=context
Thanks, that was simple and it worked. Speaking of this,
shouldn't this be documented here for example.
https://dlang
On Wednesday, 21 October 2020 at 23:54:41 UTC, bachmeier wrote:
Click the "Improve this page" link in the upper right corner
and add what you think needs to be there. Those PRs usually get
a fast response.
Will do, thank you for the direction.
On Wednesday, 21 October 2020 at 22:48:04 UTC, IGotD- wrote:
On Wednesday, 21 October 2020 at 22:41:42 UTC, Adam D. Ruppe
wrote:
try compiling with dmd -checkaction=context
Thanks, that was simple and it worked. Speaking of this,
shouldn't this be documented here for example.
https://dlang
On Wednesday, 21 October 2020 at 20:10:03 UTC, Paul Backus wrote:
On Wednesday, 21 October 2020 at 19:23:43 UTC, Simon van Bernem
wrote:
The only explanation I can think of is that D memcmps the
entire struct including the padding. Is this correct?
If so, what can I do about this? Why doesn't
23 matches
Mail list logo