On Sunday, 20 July 2025 at 20:26:02 UTC, Salih Dincer wrote:
I want the program to end with the F6 key on my keyboard
instead of the tilde. I use Windows as the platform.
Thank you for all your responses. I checked the ASCII table, and
0x1A is indeed the character I was looking for. I'm not su
On Sunday, 20 July 2025 at 21:59:48 UTC, Steven Schveighoffer
wrote:
There is no F6 Unicode character. Are you seeing tildes when
you press F6 and thinking it’s an actual tilde in the stream?
When I press the F6 key, ^Z characters appear on the screen. I
want the program to terminate using t
On Sunday, 20 July 2025 at 12:32:17 UTC, user1234 wrote:
No problem here either. Where are you running the program from
(embedded terminal in an editor ? a terminal emulator ?). Are
you on Windows or Linux ?
I want the program to end with the F6 key on my keyboard instead
of the tilde. I use
Hello D Language Forum!
I’m running the InputRange example below and it dutifully reads
from stdin until it spots a tilde, printing each character in
every loop iteration. I even tried to break out with F6 but
couldn’t get it to stop. Curiously, swapping the tilde for the
'\t' character makes
On Wednesday, 16 April 2025 at 14:48:04 UTC, H. S. Teoh wrote:
Pointers can be used perfectly fine in @safe. Just not unsafe
operations like pointer arithmetic.
So, apart from stdout.flush(), is it perfect to use the following
code with @safe:
```d
import std.stdio, std.random;
import std.
On Tuesday, 15 April 2025 at 21:06:30 UTC, WhatMeWorry wrote:
I had assumed that ref keyword negated the use of * and &
operators but when I try to use it, DMD is saying "only
parameters, functions and `foreach` declarations can be `ref`".
Fair enough. I thought that the * and & operator was fo
On Sunday, 13 April 2025 at 17:28:12 UTC, Salih Dincer wrote:
It's a very redundant thing (ASCII magic) that also weeds out
the incompatible character set.
Again and wgain opss! You can't get rid of if, but it's better
with isAlpha(), like?
```d
auto toggleCase(T)(T str)
in (str.isAsciiStr
Hi,
Please watch: https://youtu.be/siw602gzPaU
If he had learned this method like me, he would not have needed
if's and long explanations. :)
It's a very redundant thing (ASCII magic) that also weeds out the
incompatible character set. This approach adopts the toggle/flip
method through XOR
On Tuesday, 8 April 2025 at 20:14:56 UTC, Andy Valencia wrote:
p.s. Ironically, I could probably have coded a getopt in less
time than I've spent on std.getopt...
:)
Please try the following example with the parameters -h, -e, -l,
and -v in that order:
```d
import std.array : appender;
im
On Tuesday, 1 April 2025 at 09:21:25 UTC, Daniel Donnelly, Jr.
wrote:
Error: @safe function def.Def.toHash cannot call @system
function def.Def.toString: def.Def.toString is declared here...
```
I've always wondered about this, because I run into it every
time I have an idea and begin to cod
On Friday, 28 March 2025 at 12:12:45 UTC, confuzzled wrote:
I currently get this error:
sumtype.d(61): Error: cannot implicitly convert expression
`(int T) => "int"` of type `string function(int T) pure nothrow
@nogc @safe` to `immutable(string)`
private static immutable string[] typeNames
Hi everyone, I'm trying to make a search bar with buffwr. If we
go through something simple like this:
```d
module searchbar;
import raylib;
import std.string;
import std.stdio;
import std.array;
import std.algorithm;
struct Person {
string name;
string email;
}
class SearchBar {
priv
On Saturday, 22 March 2025 at 03:35:35 UTC, Andy Valencia wrote:
Consider the following, totally contrived, code. The compiler
tells me:
tst39.d(21): Error: constructor `tst39.B.this(string s)` is not
callable using argument types `()`
tst39.d(21):constructor `tst39.B.this` hides base
On Wednesday, 26 February 2025 at 19:34:24 UTC, bkoie wrote:
On Wednesday, 26 February 2025 at 16:38:20 UTC, Salih Dincer
wrote:
My_Static_Struct!ubyte(41, [0, 0, 0, 0, 0, 0, 0, 0])
My_Static_Struct!ubyte(42, [0, 0, 0, 0, 0, 0, 0, 0])
My_Dynamic_Struct!ubyte(41, [16, 32, 216, 47])
My_Dynamic_Str
On Wednesday, 26 February 2025 at 15:11:47 UTC, bkoie wrote:
stuff like this is not even necessary if you dont need it now
dont delcare an easy workaround is use some copy dictionary.
It's not that simple. I found the following code very
sympathetic. You can use the same method for structures
On Wednesday, 19 February 2025 at 23:58:09 UTC, Salih Dincer
wrote:
On Friday, 31 January 2025 at 20:05:54 UTC, Jabari Zakiya wrote:
I'm converting Ruby code to D and am running into issues.
Would appreciate what needs to be done to get it to
compile/run correctly.
I removed 1 line in your co
On Friday, 31 January 2025 at 20:05:54 UTC, Jabari Zakiya wrote:
I'm converting Ruby code to D and am running into issues.
Would appreciate what needs to be done to get it to compile/run
correctly.
First of all, I see that you don't use reserve() at all in
arrays. Since I work on a mobile pla
On Saturday, 8 June 2024 at 12:28:43 UTC, Salih Dincer wrote:
Is PR required? Why not modInverse too!
The
[std.bigint](https://github.com/dlang/phobos/blob/v2.109.1/std/bigint.d) module was prepared very harmoniously with its backend, but it seems to have been removed to the dusty pages of hi
On Saturday, 8 June 2024 at 12:28:43 UTC, Salih Dincer wrote:
Is PR required? Why not modInverse too!
```d
long extendedEuclidean(long a, long b) {
long old_r = a, r = b;
long old_s = 1, s = 0;
long old_t = 0, t = 1;
while (r != 0) {
long quotient = old_r / r;
l
On Friday, 10 January 2025 at 03:16:51 UTC, monkyyy wrote:
Well:
1) `[1,2,3,4,5].Filter!(a=>a==3).back` should equal 3, in yours
it will equal 5
Thank you for your notice. I tested your notice and I think you
are wrong. So you are confusing front() with back().
SDB@79
On Thursday, 9 January 2025 at 21:56:59 UTC, monkyyy wrote:
Im aware phoboes takes more complexity to implement filter
and there should be *some* extra complexity to make a
bidirectional filter, but when I ussally look into phoboes 1000
line functions I usually make different tradeoffs. Wha
On Thursday, 9 January 2025 at 22:01:59 UTC, WhatMeWorry wrote:
produces:
n = Node(Location(0, 0), 33)
when I expected
n = Node(Location(1, 2), 33)
This is a simple typo (it shouldn't be 1 letter) but the code
should be made smarter thanks to the capabilities of D. No more
fear of writing lik
On Wednesday, 11 December 2024 at 03:40:35 UTC, user1234 wrote:
what's the `MonoTime` equivalent of the now deprecated
`TickDuration.currSystemTick.msecs` ?
```d
import core.time;
// Get the current monotonic time
auto currentTime = MonoTime.currTime;
// Convert the MonoTime to milliseconds
l
On Tuesday, 10 December 2024 at 19:43:58 UTC, Salih Dincer wrote:
```d
auto nums = [
"zero", "one", "two", "six", "ten",
"Twenty", "Thirty"
];
alias foo = partial!(S.filter, nums);
foo('t').writeln; // okay
#line 1
//foo!(true)('t').writeln; //compile error
```
I
Hi,
I just do it directly with the S struct, why can't I filter with
partial? (#line 1)
```d
import std.stdio, std.functional : partial;
void main()
{
alias foo = partial!(S.filter, nums);
foo('t').writeln; // okay
#line 1
//foo!(true)('t').writeln; //compile error
S.filter!true(num
On Wednesday, 4 December 2024 at 21:33:46 UTC, Salih Dincer wrote:
Maybe I'm misunderstanding...
Now I get it! In fact, we bind a chosen argument. This reveals
the inadequacy of the name chosen for the library. I've made it
better by adding a few lines of code:
```d
auto hello(T)(T a, T b,
On Wednesday, 4 December 2024 at 08:50:21 UTC, axricard wrote:
Hello
I believe std.functional.partial can only apply to the first
argument.
Is there an equivalent for the Nth argument ?
Something like :
``` D
int fun(int a, int b) { return a - b; }
// create a function with the argument n°1
On Monday, 2 December 2024 at 20:27:23 UTC, Josh Holtrop wrote:
If I use `alias this` I don't know how I can get
`volatileLoad()` to be called.
Please allow me to illustrate the point with a simple example so
that you can visualize it:
```d
struct FixedStr(size_t capacity)
{
char[capacit
On Monday, 2 December 2024 at 08:00:40 UTC, Richard (Rikki)
Andrew Cattermole wrote:
You don't need both atomics an mutex's, pick one.
The compiler wants us to use atomicOp; If you want, take it out
of the synchronized(mutex) { } block, it doesn't matter:
onlineapp.d(20): Error: read-modify-
On Monday, 2 December 2024 at 02:29:39 UTC, Ali Çehreli wrote:
...
There are several other methods of communicating the request..
I've slightly edited the code that the AI generates. Ali, how is
it now, can we say that it is the best method?
```d
import core.thread;
import core.atomic;
impor
On Monday, 2 December 2024 at 02:02:56 UTC, Ritina wrote:
How can I implement a program where I have a global integer
variable g, and three threads: the first thread increments g by
1, the second thread increments g by 2, and the third thread
increments g by 3? Additionally, while these threads
On Wednesday, 27 November 2024 at 04:37:53 UTC, Richard (Rikki)
Andrew Cattermole wrote:
This is odd.
You shouldn't be getting this for a default install of dmd.
The import paths (``-I``) are not pointing at druntime inside
of sc.ini config file.
I'm also having trouble using ImportC. More a
On Thursday, 21 November 2024 at 00:34:50 UTC, WhatMeWorry` wrote:
I use this pattern very frequently throughout my code
We can't help you by seeing your pseudocode. Because when we look
at your code, instead of 3 loops, 2 loops or even a single loop
using HOFs is enough. I'm posting the foll
On Wednesday, 20 November 2024 at 11:53:09 UTC, Adrian Preuß
wrote:
I think I have found the problem: SDL2 for window creation.
Now I implemented my own window manager with contextual
graphics bindings for Vulkan, OpenGL and DirectX (9/10/11/12)
...
It seems like it can complicate things whe
On Tuesday, 19 November 2024 at 09:08:46 UTC, Adrian Preuß wrote:
I have the following project structure:
```
- main.d (Booting)
- client.d
- Renderer.d
- Manager
- SDL2.d
- GLFW.d
- RenderingTargets
- DirectX.d
- Vulkan
On Monday, 18 November 2024 at 23:43:46 UTC, Liam McGillivray
wrote:
I am doing work on the `units-d` library. This library contains
some struct templates which don't contain any variables.
Because of this, all instances are effectively constant.
However, when they are placed as arguments in ot
On Friday, 8 November 2024 at 23:27:40 UTC, Dom DiSc wrote:
I _very_ often use this pattern:
```d
fun(ref int[] a)
{
assert(a.length && a.length<=100);
int[100] b;
b[0 .. a.length-1] = a[];
b[a.length .. 100] = 5;
}
```
I consider this perfectly safe, but DScanner gives warnings for
On Wednesday, 6 November 2024 at 16:38:40 UTC, Salih Dincer wrote:
In response to Andy and Matheus, I think implementing your own
type might be a solution:
Oh, am I too hasty? There was already an s in the test
environment, so I thought 2 overloads were unnecessary. I don't
have a programmer
On Wednesday, 6 November 2024 at 16:25:40 UTC, Salih Dincer wrote:
In response to Andy and Matheus, I think implementing your own
type might be a solution:
Even in my own type, single overload was enough. So I have to
correct my mistake:
```d
void main()
{
Short foo = { -21 };
s *= -1;
On Tuesday, 5 November 2024 at 17:32:00 UTC, Andy Valencia wrote:
integral promotion not done for -val
```d
I ended up with this, but is negating a short really this
problematic, or did I miss something?
static if (!__traits(isUnsigned, T)) {
if (val < 0) {
static if
On Sunday, 3 November 2024 at 00:42:44 UTC, Kyle Ingraham wrote:
"You can add an explicit sub configuration to dub.json:
```json
"dependencies": {
"vibe-d": "~>0.10.1",
"eventcore": "~>0.9.34"
},
"subConfigurations": {
"eventcore": "kqueue"
},
```
Or you could pass --ove
On Thursday, 31 October 2024 at 08:18:58 UTC, Jordan Wilson wrote:
I've had this before, and `./install.sh update` solved it,
except for on Fedora, I couldn't for the life of me figure out
how to use the install script to install dmd (ldc and gdc
installed just fine).
Jordan
Thank you sug
The following there is error "No public key"!
```
md@SDB MSYS ~
$ curl -fsS https://dlang.org/install.sh | bash -s dmd
Downloading https://dlang.org/d-keyring.gpg
100.0%
Downloading https://dlang.org/install.sh
#
On Tuesday, 29 October 2024 at 20:26:58 UTC, DLearner wrote:
On Tuesday, 29 October 2024 at 18:57:15 UTC, Salih Dincer wrote:
DMD Compiler version?
SDB@79
```
C:\Users\SoftDev>dmd
DMD64 D Compiler v2.106.0-dirty
```
First of all, be sure to get rid of that old version because a
lot has cha
On Monday, 28 October 2024 at 20:56:03 UTC, DLearner wrote:
Just trying ImportC under Windows 10:
```c
#include
int main()
{
printf("Hello world.\n");
return 0;
}
```
Produces
```
dmd hello.c
failed launching cl.exe /P /Zc:preprocessor /PD /nologo hello.c
/FIC:\D\dmd2\windows\bin64\..\.
On Monday, 28 October 2024 at 20:53:32 UTC, Salih Dincer wrote:
Semaphore?
Please see: https://dlang.org/phobos/core_sync_semaphore.html
SDB@79
On Monday, 28 October 2024 at 19:57:41 UTC, Kyle Ingraham wrote:
- Polling too little killed performance and too often wrecked
CPU usage.
- Using message passing reduced performance quite a bit.
- Batching reads was hard because it was tricky balancing
performance for single requests with per
On Monday, 28 October 2024 at 01:06:58 UTC, Kyle Ingraham wrote:
...
The second though only achieves ~20k requests per second. In
that demo I try to make vibe.d's concurrency system available
during request handling. NGINX Unit's event loop is run in its
own thread. When requests arrive, Uni
On Wednesday, 23 October 2024 at 15:25:48 UTC, Salih Dincer wrote:
If it were me, I would equip my type with aliases like below.
But for some reason I don't understand, the enum Numbers works,
while the enum Test which is of type string doesn't!
I figured out why it wasn't working. It turns
On Wednesday, 23 October 2024 at 12:32:09 UTC, Anton Pastukhov
wrote:
I'm struggling with this code. Why `countUntil` won't work with
aliases?
```d
import std.traits : EnumMembers;
import std.algorithm : countUntil;
enum Test: string
{
One = "one",
Two = "two",
Three = "three"
}
```
On Wednesday, 23 October 2024 at 12:46:24 UTC, Paul Backus wrote:
On Wednesday, 23 October 2024 at 12:32:09 UTC, Anton Pastukhov
wrote:
There are two possible solutions to this. One is to make
`MyStruct.test` a `static` variable:
```d
// Solution #1
struct MyStruct {
static Test test = T
On Tuesday, 22 October 2024 at 10:50:22 UTC, f wrote:
std.cpp
--
```c
#include \
#include \
#include \
using namespace std;
void a(string a)
{
cout\<\<" hello " \<\libstdc++ std::__cxx11::basic_string is not yet supported; the
struct contains an interior pointer which breaks
On Friday, 18 October 2024 at 07:43:47 UTC, Richard (Rikki)
Andrew Cattermole wrote:
Sorry for not replying sooner, COVID has not been a fun virus
for my mind to have.
When a variable is declared with a struct that needs cleanup,
it effectively rewrites the following statements into a try
f
On Wednesday, 16 October 2024 at 23:54:45 UTC, Danico wrote:
https://github.com/Alinarov/D-descubrimientos
¡Bienvenido (Bienvenida ?) a nuestro D Forum! Nos alegra mucho
tenerte con nosotros. Es obvio que no estás empezando, y estamos
seguros de que tu experiencia será de gran valor para tod
On Saturday, 12 October 2024 at 13:11:52 UTC, Richard (Rikki)
Andrew Cattermole wrote:
You are not wrong, when it is a struct, it is being heap
allocated.
Sorry for prolonging the topic. I am very curious about your
answers along with your patience...
Can we say that structs are in the stack
On Saturday, 12 October 2024 at 13:08:03 UTC, Nick Treleaven
wrote:
If you want stack allocation of structs, why use `new`?
Actually, I almost never use the new operator except with(). I
was surprised because it seemed inconsistent here and wanted to
share my experiment.
On Saturday, 12 Oc
On Saturday, 12 October 2024 at 12:02:04 UTC, Salih Dincer wrote:
... even if I call the structure with the new operator. But if
I stop using classes, scope doesn't work properly!
Edit: It seems like scope is ineffective in structures. In fact,
if there is the new operator, it is as if scope d
I have a small program like below. Everything works as it should
in classes; even if I call the structure with the new operator.
But if I stop using classes, scope doesn't work properly!
```d
class/* STEP2
struct//*/
Foo {
this(int i) {
i.writefln!"Object %s is created...";
}
~this()
On Friday, 11 October 2024 at 17:58:00 UTC, Salih Dincer wrote:
There is no __traits mechanism to directly determine ...
```d
extern int x;
int y;
pragma(msg, __traits(isSame, y, x));
```
I tried it now, but as I said, it wouldn't be unreasonable:
SDB@79
On Friday, 11 October 2024 at 16:33:55 UTC, Quirin Schroll wrote:
```d
extern int x;
// int y;
```
(How) can I get the information that `x` is `extern` and `y` is
not? There seems to be no `__traits` for it.
There is no __traits mechanism to directly determine whether a
symbol is extern.
On Friday, 11 October 2024 at 03:01:54 UTC, Alexa Schor wrote:
Hello!
I've been working on building some debug print functions and
have been using the `__traits(identifier, x)` to get the name
of parameters passed into a function, trying as best I can to
replicate the functionality of the use
On Thursday, 10 October 2024 at 12:58:22 UTC, Salih Dincer wrote:
```d
class Auth
{
private:
struct PAMdata
{
string password;
string newPassword;
}
extern(C)
{ // 1. Salih changed it:
static int conversation_func(int num_msg,
const p
On Monday, 7 October 2024 at 08:23:08 UTC, Alexander Zhirov wrote:
I tried to build a class with a private function
`conversation_func` to call it inside the public authentication
function. When compiling I get this message:
```
source/login/auth.d(87,46): Deprecation: casting from extern
(C)
On Tuesday, 8 October 2024 at 15:57:24 UTC, Jared McKinnan wrote:
Hello there,
Just wanted to ask if there's a real difference between e.g.
the "long" type and "int_fast64_t" in terms of execution times.
Thanks
```int_fast64_t``` is the fastest 64-bit or larger integer type.
The type that
On Monday, 7 October 2024 at 17:20:00 UTC, ryuukk_ wrote:
We went from trying to do that:
```d
struct EntityDef
{
struct
{
int hp;
} stats;
}
```
to getting suggested to do that instead:
```d
struct Foo
{
int bar;
//struct {/*
Baz baz;
struct Baz
{
On Saturday, 5 October 2024 at 06:35:57 UTC, ryuukk_ wrote:
No, i don't want to do:
```C
struct EntityDef
{
struct Stats
{
int hp;
} stats;
}
```
Repeating the same name 3 times, i should go back to the stone
age too no?
C and all other C like languages allow me to be c
On Friday, 4 October 2024 at 08:45:49 UTC, holyzantaclara wrote:
Hello hello everyone ^_^,
I am new in D, and started this morning. I found a way to read
a file at compile time with `-J.` and `static string content =
import("my_json_file.json")`
https://dlang.org/spec/expression.html#impor
On Friday, 4 October 2024 at 12:39:45 UTC, Alexander Zhirov wrote:
On Thursday, 3 October 2024 at 23:56:37 UTC, Salih Dincer wrote
I meant taking the function to D for the elements of the C
syntax. To get only an API to which we can pass our callback,
and hide everything else inside the wrappe
On Thursday, 3 October 2024 at 22:54:53 UTC, Alexander Zhirov
wrote:
I want to try to make access via D to PAM.
```d
/// I added it here:
import pam_wrapper;
int main(string[] args)
{
if (args.length < 3)
{
writeln("Usage: ", args[0], " ");
return 1;
}
/// I added it h
On Tuesday, 1 October 2024 at 17:30:20 UTC, H. S. Teoh wrote:
On Tue, Oct 01, 2024 at 04:30:27PM +, Salih Dincer wrote:
Please add this to your MyCon structure:
```d
alias value this;
// assert(num1 == 3.14);
```
And test it like this too, I think it's awesome!
[...]
IMO it's not a good id
On Tuesday, 1 October 2024 at 16:18:17 UTC, Salih Dincer wrote:
```d
// ...
struct MyCon
{
string input;
T value;
this(string data)
{
// ...
}
// ...
}
}
```
Please add this to your MyCon structure:
```d
alias value this;
// assert(num1 == 3
On Tuesday, 1 October 2024 at 01:00:08 UTC, Andy Valencia wrote:
... A conversion like:
auto d = atoi!double("123.456");
is about 4k of code. Nice!
Congratulations on your initiative. D is very flexible with
templates, especially with the mixin templates. For example, you
might like t
On Thursday, 25 April 2024 at 03:18:36 UTC, cc wrote:
On Wednesday, 24 April 2024 at 05:08:25 UTC, Salih Dincer wrote:
Yes, `opApply()` works! You just need to use `do while()`
instead of `while()` because it skips the first item.
It depends on the type of structure being consumed, if it
prov
😁
Try the 2nd usage, D is a very flexible language; moves towards
perfection!
```d
struct Sarma {
int i;
// mixin DownRange;
}
struct Foo(T) {
int[] array;
// 1. USAGE
auto opApply(scope int delegate(T) dg) {
foreach (ref e; array)
{
On Friday, 27 September 2024 at 20:28:21 UTC, H. S. Teoh wrote:
...
The reason for (2) is that in UFCS chains, the only thing you
really only care about is what kind of range it is that you're
dealing with, and maybe the element type. What exactly the
container type is, is unimportant, and in
On Thursday, 26 September 2024 at 06:53:12 UTC, Per Nordlöw wrote:
Should a function like
```d
uint parseHex(in char ch) pure nothrow @safe @nogc {
switch (ch) {
case '0': .. case '9':
return ch - '0';
case 'a': .. case 'f':
return 10 + ch
On Thursday, 19 September 2024 at 14:30:08 UTC, Gerardo Cahn
wrote:
On Wednesday, 24 August 2022 at 08:12:33 UTC, Salih Dincer
wrote:
On Tuesday, 23 August 2022 at 23:17:21 UTC, Salih Dincer wrote:
...
Actually, both structures could be combined:
```d
struct EscapedString
{
string[1] str;
On Wednesday, 11 September 2024 at 22:06:54 UTC, WB wrote:
Honestly, D, does not really need it, and most of solutions
(like above) do have one or few limitations and drawbacks. Some
will be acceptable in some projects, some not.
There is plenty of stuff in language and library already,
add
On Wednesday, 11 September 2024 at 04:01:53 UTC, f wrote:
i mean , is this a bug?
This is not a bug. The problem is due to a misunderstanding of
the -release parameter. The following related topic opened by
Steven and the answers given by Walter are really valuable:
https://forum.dlang.org/t
On Wednesday, 11 September 2024 at 18:29:39 UTC, WB wrote:
This code is about 13 years old, but still works. (It is
functional and works, but I never it used more than what is in
this repo).
But now that we have interpolation sequences in the language,
it would be way easier, cleaner and more
On Monday, 9 September 2024 at 20:52:09 UTC, WraithGlade wrote:
In any case, this version seems more brittle than the others at
least
After all, you will need it in 2 ways: 1. to learn, 2. to test.
After testing, you can disable it with just the version parameter
while compiling. It is even p
On Monday, 9 September 2024 at 17:56:04 UTC, monkyyy wrote:
auto parse(char[] s)=>s[9..$-2];
void show(T,string file= __FILE__,int line=__LINE__)(T t){
writeln(File(file).byLine.drop(line-1).front.parse," ==
",t);
}
void main(){
int i=3;
show(i++ + ++i * i);
show(i);
}
This so
On Wednesday, 4 September 2024 at 08:58:34 UTC, Sergey wrote:
Something like:
```d
l2.byPair.filter!"a.value > 0".map!(a => a.key).writeln;
```
Thank you for your answers, my forum friends. For tuples that are
not fully integrated into the language yet, byPair() is a nice
possibility. Becaus
On Wednesday, 4 September 2024 at 08:04:58 UTC, drug007 wrote:
You should use filter instead of find. Find finds the first
element and returns the range from that first element to the
end of the original range.
Thank you, it's my mistake. We confused HOF, which has the same
first letter. So
Why doesn't t2 give the same result as t1?
```d
import std.algorithm;
import std.typecons;
alias T = Tuple!(string, "key", int, "value");
auto t1 = [T("WC", 0), T("Atelye", 0),
T("Mutfak", 41),
T("Salon", 42)
];
assert(t1.find!"a.value > 0"
.map!"a.key"
.equal(["Mu
On Sunday, 4 August 2024 at 10:06:49 UTC, aberba wrote:
So if I have a feature request, but I don't have the necessary
technical skills to draft a DIP with the implementation
details, is there a process in D community to submit such a
request?
please continue here:
https://forum.dlang.org/gro
On Tuesday, 25 June 2024 at 06:44:28 UTC, Salih Dincer wrote:
I'm not sharing the code for now because
it's a challenge.
Since we couldn't get a code snippet, I'd like to share some
framing code without answers:
```d
struct SumPrimes(size_t size)
{
import std.bigint;
auto next = BigInt
Hello, I discovered something about octal prime numbers. I don't
know if anyone has dealt with this before, but thanks to the
power of the D programming language, it was very easy. So, by
defining a range with the empty(), front() and popFront()
functions, I produced an output, something like t
On Saturday, 8 June 2024 at 18:25:20 UTC, drug007 wrote:
```d
{
const seed = castFrom!long.to!uint(Clock.currStdTime);
auto rng = Random(seed);
auto result = generate!(() => uniform(0, 10,
rng))().take(7);
// new random numbers sequence every time
re
On Saturday, 8 June 2024 at 13:19:30 UTC, Eric P626 wrote:
I just want the number of seconds elapsed since jan 1st 1970.
In other words, the internal system clock value.
#unix #time
@SDB79
On Friday, 7 June 2024 at 13:43:29 UTC, Salih Dincer wrote:
SDB@79
I have only one question: Is there a modInverse() function in
the standard library for use in RSA?
Apparently not, it fell to lot :)
I already had such a function...
```d
auto modInverse(T)(T m, T n) pure
{
T q, ilk = n;
I know there is modular exponentiation
[std.math.exponential.powmod](https://dlang.org/library/std/math/exponential/powmod.html) in the standard library.While it works great in Pyrhon (even with very large numbers), it doesn't work with signed numbers in D. That's why I turned to the alternative b
On Monday, 13 May 2024 at 15:07:39 UTC, Andy Valencia wrote:
On Sunday, 12 May 2024 at 22:03:21 UTC, Ferhat Kurtulmuş wrote:
https://dlang.org/phobos/std_container_slist.html
This is a stack, isn't it? LIFO?
Ahh yes. Then use dlist
Thank you. I read its source, and was curious so I wrote a
On Monday, 13 May 2024 at 15:07:39 UTC, Andy Valencia wrote:
Representing the FIFO as a linked list clearly has its cost,
but I found the increased system time interesting. OS memory
allocations maybe?
I know you want FIFO, I usually keep this on hand for fixed size
LIFO; It can easily con
On Wednesday, 1 May 2024 at 14:15:19 UTC, Andrey Zherikov wrote:
Shorter and without allocations:
```d
import std.typecons : tuple;
import std.algorithm : sum, each;
auto sum(int i) => i;
void main()
{
auto t = tuple(1, 2, 3, [1, 3], 5);
int res=0;
t.each!(e => res += sum(e));
assert
On Saturday, 27 April 2024 at 15:36:40 UTC, Nick Treleaven wrote:
On Saturday, 27 April 2024 at 15:32:40 UTC, Nick Treleaven
wrote:
On Saturday, 27 April 2024 at 11:55:58 UTC, Basile B. wrote:
foreach const e in u do
if echo(is, e, T) do
result += e;
You have a 5-item data tuples as Tuple(1, 2, 3, [1, 3], 5) and
implement the sum (total = 15) with the least codes using the
sum() function of the language you are coding...
Let's start with D:
```d
import std.typecons : tuple;
import std.algorithm : sum;
void main()
{
auto t = tuple(1, 2,
On Tuesday, 23 April 2024 at 06:02:18 UTC, cc wrote:
Just to offer an alternative solution (since it sometimes gets
overlooked), there is also the `opApply` approach. You don't
get full forward range status, and checking whether it's empty
essentially requires doing something like std.algorith
On Saturday, 6 April 2024 at 09:21:34 UTC, rkompass wrote:
I checked:
```d
import std.stdio,
std.range,
std.algorithm;
struct N(T)
{
T last, step, first;
bool empty() => first >= last;
T front() => first;
auto popFront() => first += step;
}
void main() {
auto r1 = N!si
On Friday, 5 April 2024 at 14:41:12 UTC, Carl Sturtivant wrote:
On Friday, 5 April 2024 at 07:37:20 UTC, Paolo Invernizzi wrote:
pragma(msg, x) ?
No.
`__ctfeWrite(x)` is executed inside an executing function like
any other statement in it, and can have an argument `x`
computed during that e
1 - 100 of 457 matches
Mail list logo