On Sunday, 17 May 2020 at 09:41:55 UTC, Johan wrote:
On Sunday, 17 May 2020 at 03:30:57 UTC, Adnan wrote:
Hello, I am trying to examine what causes my similar D
solution to lag behind performance.
In the link, they don't have ldc or gdc but according to my
machine, the dmd generated code
On Sunday, 17 May 2020 at 11:39:30 UTC, kinke wrote:
As a side note, using jagged arrays for multiple dimensions
should probably be avoided whenever you can.
By jagged array, do you mean vector of vectors? What would be an
alternative?
Hello, I am trying to examine what causes my similar D solution
to lag behind performance.
In the link, they don't have ldc or gdc but according to my
machine, the dmd generated code isn't really far behind ldc
generated code.
So here is the actual code:
ulong levenshteinEditDistance(T)(in
In my naive implementation of edit-distance finder, I have to
check whether the last characters of two strings match:
ulong editDistance(const string a, const string b) {
if (a.length == 0)
return b.length;
if (b.length == 0)
return a.length;
const auto delt =
On Monday, 13 April 2020 at 23:59:20 UTC, Adnan wrote:
I want to keep an ordered set of records and the standard
provides me with RedBlackTree. The record is of type
Tuple!(string, uint). Here's what it looks like:
import std.json : parseJSON;
uint[string] wordTable;
import
I want to keep an ordered set of records and the standard
provides me with RedBlackTree. The record is of type
Tuple!(string, uint). Here's what it looks like:
import std.json : parseJSON;
uint[string] wordTable;
import std.datetime.stopwatch : StopWatch, AutoStart;
I'm a bit confused about D's development process. I've seen
people discussing DIPs in Github. I've also seen people discuss
internal issues in bugzilla. How do these to correlate?
I'm not very familiar with bugzilla, last time I reported an
issue about a documentation in the std, I was
On Monday, 13 April 2020 at 21:31:49 UTC, Adnan wrote:
I'm a bit confused about D's development process. I've seen
people discussing DIPs in Github. I've also seen people discuss
internal issues in bugzilla. How do these to correlate?
I'm not very familiar with bugzilla, last time I reported
On Monday, 13 April 2020 at 02:22:33 UTC, Adam D. Ruppe wrote:
On Monday, 13 April 2020 at 02:20:39 UTC, Adnan wrote:
Now in the above inner loop getStr(node["com"].str()) crashes
in runtime if an array does not contain "com" node. I want to
avoid that. How should I proceed?
Try:
if("com"
In the following code, I want to process an json array (returned
by the value of "posts") that might or might not have "com" key.
If a "com" key does not exist, I want to ignore that item in the
json array.
uint[string] wordTable;
const auto j = parseJSON(get(link));
On Monday, 16 March 2020 at 13:09:08 UTC, Adnan wrote:
On Sunday, 15 March 2020 at 00:37:35 UTC, H. S. Teoh wrote:
On Sat, Mar 14, 2020 at 10:37:37PM +, Adnan via
Digitalmars-d-learn wrote:
https://dlang.org/library/std/mmfile/mm_file.html doesn't
seem to
specify anything similar to lines
On Sunday, 15 March 2020 at 00:37:35 UTC, H. S. Teoh wrote:
On Sat, Mar 14, 2020 at 10:37:37PM +, Adnan via
Digitalmars-d-learn wrote:
https://dlang.org/library/std/mmfile/mm_file.html doesn't seem
to
specify anything similar to lines() or byLine() or
byLineCopy() etc.
That's because
On Sunday, 15 March 2020 at 00:04:09 UTC, Adnan wrote:
On Saturday, 14 March 2020 at 23:54:44 UTC, Adam D. Ruppe wrote:
On Saturday, 14 March 2020 at 23:39:11 UTC, Adnan wrote:
Full code
this worked for me when i copy/pasted it... are you sure that
has the error? if so what compiler version
On Saturday, 14 March 2020 at 23:54:44 UTC, Adam D. Ruppe wrote:
On Saturday, 14 March 2020 at 23:39:11 UTC, Adnan wrote:
Full code
this worked for me when i copy/pasted it... are you sure that
has the error? if so what compiler version you on?
This is indeed very strange, godbolt says
On Saturday, 14 March 2020 at 23:39:11 UTC, Adnan wrote:
In the following code the compiler says the type is
Array!()(string):
if (key in wordTable)
wordTable[key] ~= word;
else
In the following code the compiler says the type is
Array!()(string):
if (key in wordTable)
wordTable[key] ~= word;
else
wordTable[key] = Array!string(word);
source/app.d(29,36):
https://dlang.org/library/std/mmfile/mm_file.html doesn't seem to
specify anything similar to lines() or byLine() or byLineCopy()
etc.
In my machine the following D code compiled with release flag and
LDC performs over 230ms while the similar Go code performs under
120ms.
string smallestRepr(const string arg) {
import std.format : format;
const repeated = format!"%s%s"(arg, arg);
string result;
The following program produces an error message and it is not
clear exactly what line causes this error:
module maybe;
@nogc:
private import std.container : Array;
struct MayBe(T) {
Array!T data;
this(T datum) {
data.reserve(1);
On Saturday, 29 February 2020 at 13:03:21 UTC, Sebastiaan Koppe
wrote:
On Saturday, 29 February 2020 at 12:50:59 UTC, Adnan wrote:
* Option!T from the optional package: Has even worse problem
IMO. Not only it allows None + int but also it returns a `[]`.
This API is not to my liking. You could
I have a struct that has to arrays. Each of those must have the
same sizes.
So while constructing the array, if you pass two arrays of
different sizes the constructor must return nothing.
In Rust I could easily use Option. D has no answer to Optional
types as far as I am concerned. Is
In Rust they have $cargo new --lib
Even if dub doesn't have this, how can I change dub.json to build
it as a library and not look for the main function?
What is the alternative to C++'s friend functions in D?
module stable_matching;
alias FemaleID = int;
alias MaleID = int;
class Person {
string name;
int id;
}
class Male : Person {
this(string name = "Unnamed Male") {
static int nextID = 0;
this.id = nextID++;
I have a base class that has a couple of constant member
variables. These variables are abstract, they will only get
defined when the derived class gets constructed.
class Person {
const string name;
const int id;
}
class Male : Person {
this(string name = "Unnamed Male") {
On Monday, 17 February 2020 at 14:34:44 UTC, Simen Kjærås wrote:
On Monday, 17 February 2020 at 14:04:34 UTC, Adnan wrote:
//
All in all, I end up with this code:
module strassens_matmul
package {
T[][] mulIterative(T)(const T[][] mat1, const T[][] mat2) {
auto result =
On Monday, 17 February 2020 at 14:04:34 UTC, Adnan wrote:
On Monday, 17 February 2020 at 13:44:55 UTC, Adnan wrote:
[...]
Okay I changed to
module strassens_matmul;
[...]
I changed getPointPtr to following and now it works
/// row and column are 0 index-based
void assign(T)(ref
On Monday, 17 February 2020 at 13:44:55 UTC, Adnan wrote:
https://ideone.com/lVi5Uy
module strassens_matmul;
debug {
static import std;
}
...
Okay I changed to
module strassens_matmul;
debug {
static import std;
}
package {
ulong getRowSize(T)(scope const T[][] mat) {
https://ideone.com/lVi5Uy
module strassens_matmul;
debug {
static import std;
}
package {
ulong getRowSize(T)(T[][] mat) {
return mat[0].length;
}
ulong getColumnSize(T)(T[][] mat) {
return mat.length;
}
T[][] createMatrix(T)(const ulong rowSize, const
On Monday, 17 February 2020 at 07:50:02 UTC, Mitacha wrote:
On Monday, 17 February 2020 at 05:04:02 UTC, Adnan wrote:
What is the equivalent of Rust's chunks_exact()[1] method in
D? I want to iterate over a spitted string two chunks at a
time.
[1]
What is the equivalent of Rust's chunks_exact()[1] method in D? I
want to iterate over a spitted string two chunks at a time.
[1]
https://doc.rust-lang.org/beta/std/primitive.slice.html#method.chunks_exact
I am debugging my simple binary search (I still am):
module binary_search;
debug {
static import std;
}
int indexOf(T)(const T[] list, const T key) {
ulong lo = 0;
ulong hi = list.length - 1;
while (hi > lo) {
const ulong mid = lo + (hi - lo) / 2;
if (list[mid]
How can I reach stdout.writeln() using fully qualified name with
static import?
I have tried:
std.stdio.stdout.writeln() -- fails
std.writeln() -- works
std.stdout.writeln -- works
How does static import with std work?
On Tuesday, 11 February 2020 at 13:45:24 UTC, kinke wrote:
On Tuesday, 11 February 2020 at 13:38:32 UTC, Adnan wrote:
I just want to know is there any de-facto way of achieving
this?
See the `-checkaction=context` switch.
Exactly what I was after. Thanks.
Hi, is there any trick to print the RHS and the LHS of the assert
expressions when it fails?
like `assert(2 == 5)` should fail and print something like:
... assert failed [__LINE__/__MODULE__]: Left hand side: 2 is 2,
Right hand side: 5 is 5
Of course, I can design a function to do so
Just a foreword, this is for learning purposes, hence I am not
using the dynamic array or Array!T.
I have a structure that maintains a heap allocated sized array
inside.
struct LifoStack(T) {
T[?] data;
}
This `data` is manually resized and copied. Thus the size itself
is not a compile
https://wiki.dlang.org/Dense_multidimensional_arrays#Static_arrays describes a
way to create static arrays:
int[3][3] matrix = [
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
];
However my complains that I can't implicitly create static arrays
from dynamic arrays.
private T[R1][C2]
How would someone approach parsing epub files in D? Is there any
libraries to parse XHTML?
This is not entirely a D question, but I'm not sure what about my
mergesort implementation went wrong.
T[] merge(T)(T[] arr1, T[] arr2) {
T[] result;
result.reserve(arr1.length + arr2.length);
ulong arr1_idx = 0, arr2_idx = 0;
while (arr1_idx < arr1.length && arr2_idx <
Does the compiler automatically pass values by reference if
possible with `in` parameters in higher level of optimization
flags? I would normally use `in ref` but sometimes it's not
compatible with different types.
Hello, how does one:
1. Force static linking (build with `-defaultlib` flag)
2. Specify binary file generated by the `dub buid` command
3. Specify binary file generated by the `dub test` command
in the `dub.json` file?
On Thursday, 10 October 2019 at 12:30:25 UTC, Hossain Adnan wrote:
Here I have a program that wants to
1. detect whether if it's the only instance
1.1. it does that by trying to create a Unix Domain Socket
and trying to binding it to a specific address.
2. if a duplicate program is not
On Thursday, 10 October 2019 at 12:30:25 UTC, Hossain Adnan wrote:
Here I have a program that wants to
1. detect whether if it's the only instance
1.1. it does that by trying to create a Unix Domain Socket
and trying to binding it to a specific address.
[...]
If it helps explaining
Here I have a program that wants to
1. detect whether if it's the only instance
1.1. it does that by trying to create a Unix Domain Socket
and trying to binding it to a specific address.
2. if a duplicate program is not running, establish an UDS
and then listen to the socket.
On Saturday, 28 September 2019 at 13:37:12 UTC, Kagamin wrote:
https://ddbus.dpldocs.info/ddbus.bus.requestName.html
It requires a Connection type which I cannot find in the API.
On Wednesday, 25 September 2019 at 11:46:04 UTC, Ron Tarrant
wrote:
Hi y'all,
I've been Googling how to do this, but coming up with nothing
definitive. Are there any articles for how to do this for:
Linux?
For Linux there are 3 new options:
1. Appimages (https://appimage.org/): This is
Hi I need to detect application uniqueness using dbus. I have a
working code in Rust:
fn run_as_unique_instance() {
println!("First instance detected. Doing work...");
loop {}
}
fn run_as_nonunique_instance() {
println!("Another instance is already running. Quiting...");
Hello. Is code-review requests welcome in this forum? If so I
would like some criticisms and feedback for my disjoint sets
implementation. The code is as follows:
module dsets;
/// dsets is an implementation of disjoint sets. It is implemented
/// with a simple class. To construct it, you
Does anyone have experience with using meson to wrap around a dub
project?
I have a typical dub project, meaning I have a dub dependency but
I want to use meson for two reasons:
1. I want to distribute the application in form of a snap package
(https://snapcraft.io/). Snapcraft does not
On Tuesday, 20 November 2018 at 18:54:58 UTC, Adnan wrote:
Godbolt: https://godbolt.org/z/SWWOu7
When I write `something!(aNumber)()` and if a number is an
immutable/enum it should be able to be read at compile time,
right? Why is this different?
auto fizzbuzz(uint N)() {
static string
Godbolt: https://godbolt.org/z/SWWOu7
When I write `something!(aNumber)()` and if a number is an
immutable/enum it should be able to be read at compile time,
right? Why is this different?
auto fizzbuzz(uint N)() {
static string accumulate;
return fizzbuzz!N(accumulate);
}
auto
50 matches
Mail list logo