On Monday, 13 January 2025 at 14:52:05 UTC, Matheus Catarino
wrote:
On Monday, 13 January 2025 at 11:36:45 UTC, Dakota wrote:
You could simply use dstep or dmd/ldc2 `-H`|`-Hf=`.
Thanks for tips.
My point is c allot align to alias, is D support it ?
I want avoid importC, because I want to w
On Monday, 13 January 2025 at 11:36:45 UTC, Dakota wrote:
I want tranlate this into d without importC, what is the best
way to do it?
When you say "without importC" do you mean without compiling it
using importC? Because if you're able to use importC for just the
translation, you can put the
On Monday, 13 January 2025 at 11:36:45 UTC, Dakota wrote:
I want tranlate this into d without importC, what is the best
way to do it?
You could simply use dstep or dmd/ldc2 `-H`|`-Hf=`.
My test on linux shows that both can translate/convert the file.
Although there are differences such as:
```c
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
# include
#endif
#if defined(_MSC_VER)
/* do not use alignment for older visual studio versions */
# if _MSC_VER < 1913 /* Visual Studio 2017 version 15.6 */
#define CGLM_ALL_UNALIGNED
#define CGLM_ALIGN(X) /* no alig
On Wednesday, 20 September 2023 at 13:53:08 UTC, Ki Rill wrote:
Here is the macro:
```C
#define NK_CONTAINER_OF(ptr,type,member)\
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) -
NK_OFFSETOF(type, member)))
```
I'm trying to translate the Nuklear GUI library to D
[here](https://
On Thursday, 21 September 2023 at 16:50:51 UTC, Imperatorn wrote:
On Wednesday, 20 September 2023 at 13:53:08 UTC, Ki Rill wrote:
Here is the macro:
```C
#define NK_CONTAINER_OF(ptr,type,member)\
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) -
NK_OFFSETOF(type, member)))
```
I'
On Thursday, 21 September 2023 at 16:28:25 UTC, Nick Treleaven
wrote:
The 1st argument of `getMember` can just be T, like the
original macro.
The 2nd argument needs to be a compile-time string.
Also the `char*` cast needs to apply to `ptr` before
subtracting the offset AFAICS.
So reordering
On Wednesday, 20 September 2023 at 13:53:08 UTC, Ki Rill wrote:
Here is the macro:
```C
#define NK_CONTAINER_OF(ptr,type,member)\
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) -
NK_OFFSETOF(type, member)))
```
I'm trying to translate the Nuklear GUI library to D
[here](https://
On Thursday, 21 September 2023 at 16:28:25 UTC, Nick Treleaven
wrote:
(Untested)
There might be a `need this` error
On Thursday, 21 September 2023 at 16:28:25 UTC, Nick Treleaven
wrote:
return cast(T*)(cast(void*)(cast(char*)ptr -
__traits(getMember, T, member).offsetof)));
There's a trailing `)` that needs removing. Also pretty sure it
can be simplified to:
return cast(T*)(cast(char*)ptr
On Thursday, 21 September 2023 at 02:57:07 UTC, Ki Rill wrote:
On Thursday, 21 September 2023 at 02:23:32 UTC, Ki Rill wrote:
wrote:
[...]
Translated it to this eventually:
```D
auto nk_container_of(P, T)(P ptr, T type, const(char)* member)
{
return cast(T*)(cast(void*)(cast(char*)
On Thursday, 21 September 2023 at 02:23:32 UTC, Ki Rill wrote:
wrote:
[...]
Translated it to this eventually:
```D
auto nk_container_of(P, T)(P ptr, T type, const(char)* member)
{
return cast(T*)(cast(void*)(cast(char*)
(ptr - __traits(getMember, type, member).offsetof)));
}
```
On Wednesday, 20 September 2023 at 17:14:41 UTC, Dejan Lekic
wrote:
[...]
NK_CONTAINER_OF should probably be translated to:
`cast(T*)((cast(void*)ptr - __traits(getMember, T,
member).offsetof))`
PS. I did not invent this. My original idea was far worse than
this. - It was suggested on IRC b
On Wednesday, 20 September 2023 at 13:55:14 UTC, Ki Rill wrote:
On Wednesday, 20 September 2023 at 13:53:08 UTC, Ki Rill wrote:
Here is the macro:
```C
#define NK_CONTAINER_OF(ptr,type,member)\
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) -
NK_OFFSETOF(type, member)))
```
I'm
On Wednesday, 20 September 2023 at 13:53:08 UTC, Ki Rill wrote:
Here is the macro:
```C
#define NK_CONTAINER_OF(ptr,type,member)\
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) -
NK_OFFSETOF(type, member)))
```
I'm trying to translate the Nuklear GUI library to D
[here](https://
On Wednesday, 20 September 2023 at 13:55:14 UTC, Ki Rill wrote:
On Wednesday, 20 September 2023 at 13:53:08 UTC, Ki Rill wrote:
Here is the macro:
```C
#define NK_CONTAINER_OF(ptr,type,member)\
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) -
NK_OFFSETOF(type, member)))
```
I'm
On Wednesday, 20 September 2023 at 13:53:08 UTC, Ki Rill wrote:
Here is the macro:
```C
#define NK_CONTAINER_OF(ptr,type,member)\
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) -
NK_OFFSETOF(type, member)))
```
I'm trying to translate the Nuklear GUI library to D
[here](https://
Here is the macro:
```C
#define NK_CONTAINER_OF(ptr,type,member)\
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) -
NK_OFFSETOF(type, member)))
```
I'm trying to translate the Nuklear GUI library to D
[here](https://github.com/rillki/nuklear-d/tree/nuklear-d-translation).
On Friday, 17 February 2023 at 17:03:34 UTC, ron77 wrote:
Hello, I succeeded in converting an ELIZA code from C to D, and
here are the results. although I'm sure there are better ways
to code it or to convert it...
```d
/* eliza.c
* ys
* original code by Weizenbaum, 1966
* this rend
On Friday, 17 February 2023 at 17:03:34 UTC, ron77 wrote:
Hello, I succeeded in converting an ELIZA code from C to D, and
here are the results. although I'm sure there are better ways
to code it or to convert it...
this is nothing compared to chatgpt ;)
On Friday, 17 February 2023 at 17:03:34 UTC, ron77 wrote:
Hello, I succeeded in converting an ELIZA code from C to D, and
here are the results. although I'm sure there are better ways
to code it or to convert it...
[...]
Among the things to do the first is to drop C-style strings, so
Hello, I succeeded in converting an ELIZA code from C to D, and
here are the results. although I'm sure there are better ways to
code it or to convert it...
```d
/* eliza.c
* ys
* original code by Weizenbaum, 1966
* this rendition based on Charles Hayden's Java implementation
On Tuesday, 24 August 2021 at 11:52:45 UTC, Dennis wrote:
On Saturday, 21 August 2021 at 08:14:22 UTC, Виталий Фадеев
wrote:
Any more ?
CPP2D
https://github.com/lhamot/CPP2D
Dennis, thank!
On Saturday, 21 August 2021 at 08:14:22 UTC, Виталий Фадеев wrote:
Any more ?
CPP2D
https://github.com/lhamot/CPP2D
On Saturday, 21 August 2021 at 08:59:55 UTC, evilrat wrote:
On Saturday, 21 August 2021 at 08:14:22 UTC, Виталий Фадеев
wrote:
I know, i know... It not possible, but part of the C code we
can to convert to the D.
Show me, please, solutions, projects, tools, scripts, docs.
Can you give the link
On Saturday, 21 August 2021 at 08:14:22 UTC, Виталий Фадеев wrote:
I know, i know... It not possible, but part of the C code we
can to convert to the D.
Show me, please, solutions, projects, tools, scripts, docs.
Can you give the link ?
`htod` is 1.
Any more ?
dstep
https://code.dlang.org/pac
I know, i know... It not possible, but part of the C code we can
to convert to the D.
Show me, please, solutions, projects, tools, scripts, docs.
Can you give the link ?
Examples of what the wanted:
// C
typedef struct {
uint32_t version; /* 0x5000 */
uin
On Thursday, 10 June 2021 at 19:06:42 UTC, Tejas wrote:
But how scalable will this be? We have to get real D code to
enrich our ambiguously-defined-small ecosystem.
It says bindings generator, but it has to convert the code
keeping the semantic as close as possible.
It does direct translat
em applies with translating C++ to D:
https://scottmeyers.blogspot.com/2015/11/the-brick-wall-of-c-source-code.html
Damn that preprocessor! :@
7;t need a nogc compatible
std library and so many other things could get easier, like
getting legacy code to use Dlang. It might not be worth it for
C+17 and beyond, but older codebases could benefit
significantly, right?
I leave this here, it does converts C++ to D to some extent
https://github
On Thursday, 10 June 2021 at 15:09:02 UTC, Tejas wrote:
Sorry, I'm rather ignorant when it comes to this, but why can't
we use [pegged](https://github.com/PhilippeSigaud/Pegged) to
transpile C++ code to D?
See
https://stackoverflow.com/questions/14589346/is-c-context-free-or-context-sensitive
hings could get easier, like
getting legacy code to use Dlang. It might not be worth it for
C+17 and beyond, but older codebases could benefit
significantly, right?
I leave this here, it does converts C++ to D to some extent
https://github.com/Superbelko/ohmygentool
On Thursday, 10 June 2021 at 15:57:44 UTC, Imperatorn wrote:
On Thursday, 10 June 2021 at 15:09:02 UTC, Tejas wrote:
Sorry, I'm rather ignorant when it comes to this, but why
can't we use
[pegged](https://github.com/PhilippeSigaud/Pegged) to
transpile C++ code to D? Then we won't need a nogc c
hings could get easier, like
getting legacy code to use Dlang. It might not be worth it for
C+17 and beyond, but older codebases could benefit
significantly, right?
This is article is about transpiling old C++ to newer C++, but
the same problem applies with translating C++ to D:
https://scottmeye
On Thursday, 10 June 2021 at 15:09:02 UTC, Tejas wrote:
Sorry, I'm rather ignorant when it comes to this, but why can't
we use [pegged](https://github.com/PhilippeSigaud/Pegged) to
transpile C++ code to D? Then we won't need a nogc compatible
std library and so many other things could get easie
Sorry, I'm rather ignorant when it comes to this, but why can't
we use [pegged](https://github.com/PhilippeSigaud/Pegged) to
transpile C++ code to D? Then we won't need a nogc compatible std
library and so many other things could get easier, like getting
legacy code to use Dlang. It might not b
On Wed, Feb 21, 2018 at 11:16:44PM -0500, Nick Sabalausky (Abscissa) via
Digitalmars-d-learn wrote:
> Are there any tutorials or articles out there for "getting started
> with converting a C++ codebase to D one module at a time?" Or at the
> very least: tips, tricks, lessions learned, from those w
ome before.
AFAIK, visuald has a tool that just translated C++ to D
https://github.com/dlang/visuald/tree/master/c2d
our favorite regexp search-and-replace
tool) alot. basically, before HDD crash i almost had a set of
scripts that does 80-90 percents of work translating C to D
with sed. ;-) then use editor with "jump to error line"
support, and simply compile your code, fixing errors one by one.
tip:
On Thu, Feb 22, 2018 at 10:43:24AM +0200, ketmar via Digitalmars-d-learn wrote:
> Nick Sabalausky (Abscissa) wrote:
>
> > Are there any tutorials or articles out there for "getting started
> > with converting a C++ codebase to D one module at a time?" Or at the
> > very least: tips, tricks, lessio
ode, up to the whole codebase. it is not
> fun when compler spits 100500 errors, but when it finally stops... oh, joy!
>
> trick: use 'sed' (or your favorite regexp search-and-replace tool) alot.
> basically, before HDD crash i almost had a set of scripts that does 80-90
&g
code, up to the whole codebase. it is
not fun when compler spits 100500 errors, but when it finally stops... oh,
joy!
trick: use 'sed' (or your favorite regexp search-and-replace tool) alot.
basically, before HDD crash i almost had a set of scripts that does 80-90
percents of work t
On Thursday, 22 February 2018 at 04:16:44 UTC, Nick Sabalausky
(Abscissa) wrote:
Are there any tutorials or articles out there for "getting
started with converting a C++ codebase to D one module at a
time?" Or at the very least: tips, tricks, lessions learned,
from those who have come before.
Are there any tutorials or articles out there for "getting started with
converting a C++ codebase to D one module at a time?" Or at the very
least: tips, tricks, lessions learned, from those who have come before.
On Tuesday, 28 November 2017 at 09:01:47 UTC, Temtaime wrote:
https://pastebin.com/xJXPBh0n
Converted it and it works as expected.
What did you use for it?
In future I'll be needed to convert some more C++ code.
P.S. /And it works wrong, because uses unsafe pointer (ubyte
*image). So, it takes
On Tuesday, 28 November 2017 at 06:46:18 UTC, Dmitry wrote:
On Monday, 27 November 2017 at 19:01:28 UTC, Ali Çehreli wrote:
P.S. I think you have an unnecessary 'ref' on the D version
because a slice is already a reference to elements:
Fixed, thank you.
https://pastebin.com/xJXPBh0n
Converted
On Monday, 27 November 2017 at 19:01:28 UTC, Ali Çehreli wrote:
P.S. I think you have an unnecessary 'ref' on the D version
because a slice is already a reference to elements:
Fixed, thank you.
On 11/27/2017 10:47 AM, Dmitry wrote:
> On Monday, 27 November 2017 at 18:40:41 UTC, Ali Çehreli wrote:
>
>> So, it looks like the original code was accessing out of bounds and
>> probably that's why you inserted the ((index + 3) < N) check in the D
>> version because D was catching that error at
On Monday, 27 November 2017 at 18:40:41 UTC, Ali Çehreli wrote:
So, it looks like the original code was accessing out of bounds
and probably that's why you inserted the ((index + 3) < N)
check in the D version because D was catching that error at
runtime.
Yes, it is.
Which of course would sk
On 11/27/2017 10:25 AM, Dmitry wrote:
> On Monday, 27 November 2017 at 17:21:05 UTC, Dmitry wrote:
>> It fixed a delay (you can see it on video I posted before), but result
>> is same.
>
> It seems I found the problem.
>
> C++ version (line 93):
> if (image[index + 3] != 0)
>
> I changed to
> if (
On Monday, 27 November 2017 at 17:21:05 UTC, Dmitry wrote:
It fixed a delay (you can see it on video I posted before), but
result is same.
It seems I found the problem.
C++ version (line 93):
if (image[index + 3] != 0)
I changed to
if (image[index] != 0)
and it works.
I don't understand why
On Monday, 27 November 2017 at 17:01:29 UTC, Adam D. Ruppe wrote:
In the C++ version they are declared
std::vector pending;
std::vector pendingNext;
Ah, indeed. I thought that
pending.reserve(N);
pendingNext.reserve(N);
initializes them (last time I used C++ about 17 years ago...)
I suspect
On Monday, 27 November 2017 at 14:35:39 UTC, Stefan Koch wrote:
First I'd make sure that what you get out of dlib load is the
same as the c++ version gets.
Just use standard debugging techniques.
Yes, it's same. As you can see, the top-middle area of the result
is same.
I wrote a video of p
On Monday, 27 November 2017 at 14:08:27 UTC, Dmitry wrote:
https://pastebin.com/GzZQ7WHt
The first thing that jumped out to me is this:
size_t[] pending = new size_t[N];
size_t[] pendingNext = new size_t[N];
That's giving it N elements of zero, then you append to it later
with
On Monday, 27 November 2017 at 14:08:27 UTC, Dmitry wrote:
I tried translate C++ programm to D, but result is different.
original:
https://github.com/urraka/alpha-bleeding/blob/master/src/alpha-bleeding.cpp
result (with removed alpha):
https://github.com/urraka/alpha-bleeding/blob/master/media/a
On Monday, 27 November 2017 at 14:14:12 UTC, rikki cattermole
wrote:
Did you confirm that the image was loaded originally correctly?
Yes.
This image was used:
https://github.com/urraka/alpha-bleeding/blob/master/media/original.png
Did you confirm that the image was loaded originally correctly?
I tried translate C++ programm to D, but result is different.
original:
https://github.com/urraka/alpha-bleeding/blob/master/src/alpha-bleeding.cpp
result (with removed alpha):
https://github.com/urraka/alpha-bleeding/blob/master/media/alpha-bleeding-opaque.png
my:
https://pastebin.com/GzZQ7WHt
On Sunday, 2 April 2017 at 16:03:51 UTC, FreeSlave wrote:
Funny thing: If I replace interface with abstract class, it
works as it should.
Also I noticed that removing inheritance in library and in
application makes unexpected results. When I try to output field
`field` I get incorrect rando
On Sunday, 2 April 2017 at 16:03:51 UTC, FreeSlave wrote:
On Sunday, 2 April 2017 at 16:02:06 UTC, FreeSlave wrote:
On Sunday, 2 April 2017 at 09:58:19 UTC, ANtlord wrote:
[...]
Now I see. 'Using C++ Classes From D' crashes for me too. It
also returns the wrong value from 'field' method. Sho
On Sunday, 2 April 2017 at 16:02:06 UTC, FreeSlave wrote:
On Sunday, 2 April 2017 at 09:58:19 UTC, ANtlord wrote:
On Saturday, 1 April 2017 at 16:39:28 UTC, FreeSlave wrote:
This page has many examples. Which exactly do you try to run
and how do you build it? Which compilers, OS?
My bad. I've
On Sunday, 2 April 2017 at 09:58:19 UTC, ANtlord wrote:
On Saturday, 1 April 2017 at 16:39:28 UTC, FreeSlave wrote:
This page has many examples. Which exactly do you try to run
and how do you build it? Which compilers, OS?
My bad. I've tested example under caption Using C++ Classes
From D. I
On Sunday, 2 April 2017 at 09:58:19 UTC, ANtlord wrote:
On Saturday, 1 April 2017 at 16:39:28 UTC, FreeSlave wrote:
This page has many examples. Which exactly do you try to run
and how do you build it? Which compilers, OS?
My bad. I've tested example under caption Using C++ Classes
From D. I
On Saturday, 1 April 2017 at 16:39:28 UTC, FreeSlave wrote:
This page has many examples. Which exactly do you try to run
and how do you build it? Which compilers, OS?
My bad. I've tested example under caption Using C++ Classes From
D. I used several combinations of compilers, and no one works
On Saturday, 1 April 2017 at 07:37:25 UTC, ANtlord wrote:
Hello!
Can somebody give a relevant example shows how to use C++
classes in D? I've used the exmaple from
https://dlang.org/spec/cpp_interface.html but I get a
segmentation fault as result of D application. My application
shows "Progr
Hello!
Can somebody give a relevant example shows how to use C++ classes
in D? I've used the exmaple from
https://dlang.org/spec/cpp_interface.html but I get a
segmentation fault as result of D application. My application
shows "Program exited with code -11"
Thanks.
On Sunday, 3 May 2015 at 17:46:54 UTC, Meta wrote:
This is not really doable right now in D. You can forward the
function calls to a and b easily enough, but you can't inherit
from more than one class. Once the multiple alias this patch
gets merged you will be able to do this in D.
On Sunday,
On Sunday, 3 May 2015 at 17:35:42 UTC, Dennis Ritchie wrote:
Hi,
How can I rewrite this code to the D?
-
#include
#include
class A {
public:
std::string a() {
return std::string("foo");
}
};
class B {
public:
std::string b(){
return std::string(
I'd make class A and class B into mixin templates instead.
mixin template A {
string a() { return "foo"; }
}
mixin template B {
string b() { return "bar"; }
}
class C {
mixin A;
mixin B;
}
If you still need class A and class B, just make a class that
mixes in the template for them
On Sunday, 3 May 2015 at 17:35:42 UTC, Dennis Ritchie wrote:
Hi,
How can I rewrite this code to the D?
-
#include
#include
class A {
public:
std::string a() {
return std::string("foo");
}
};
class B {
public:
std::string b(){
return std::string(
Hi,
How can I rewrite this code to the D?
-
#include
#include
class A {
public:
std::string a() {
return std::string("foo");
}
};
class B {
public:
std::string b(){
return std::string("bar");
}
};
class C : public A, public B {};
int main
On Sunday, 5 April 2015 at 09:48:01 UTC, thedeemon wrote:
On Friday, 3 April 2015 at 16:46:08 UTC, Dennis Ritchie wrote:
Hi,
Is it possible to write on D recursion using std.variant?
Using Algebraic from std.variant and some additional templates:
http://dpaste.dzfl.pl/65afd3a7ce52
(taken from
On Friday, 3 April 2015 at 16:46:08 UTC, Dennis Ritchie wrote:
Hi,
Is it possible to write on D recursion using std.variant?
Using Algebraic from std.variant and some additional templates:
http://dpaste.dzfl.pl/65afd3a7ce52
(taken from this thread:
http://forum.dlang.org/thread/yidovyrczgdiveq
Hi,
Is it possible to write on D recursion using std.variant?
-
#include
#include
struct Nil {};
auto nil = Nil{};
template
struct Cons;
template
using List = boost::variant>>;
template
struct Cons {
Cons(T val, List list) : head(val), tail(list) {}
T head;
L
On Wednesday, 1 April 2015 at 17:51:40 UTC, John Colvin wrote:
Don't really see the point. Here's a neat thing that's
definitely cheating because although it stores the results in
the type system, the arithmetic is done in constant-folding:
struct Integer(int a){}
template Value(T)
{
stati
On Wednesday, 1 April 2015 at 17:51:40 UTC, John Colvin wrote:
On Wednesday, 1 April 2015 at 17:03:34 UTC, Dennis Ritchie
wrote:
On Wednesday, 1 April 2015 at 15:22:10 UTC, John Colvin wrote:
Compile Time Function Evaluation (CTFE) is a very powerful
tool
to avoid having to enter in to all tha
On Wednesday, 1 April 2015 at 17:03:34 UTC, Dennis Ritchie wrote:
On Wednesday, 1 April 2015 at 15:22:10 UTC, John Colvin wrote:
Compile Time Function Evaluation (CTFE) is a very powerful tool
to avoid having to enter in to all that C++ style mess.
Yes, CTFE in D really cool. Thanks.
I need t
On Wednesday, 1 April 2015 at 15:22:10 UTC, John Colvin wrote:
Compile Time Function Evaluation (CTFE) is a very powerful tool
to avoid having to enter in to all that C++ style mess.
Yes, CTFE in D really cool. Thanks.
I need to implement arithmetic (addition / subtraction) only use
the type
On Wednesday, 1 April 2015 at 13:59:10 UTC, Dennis Ritchie wrote:
You can do this:
import std.typetuple;
//helper for staticReduce
template Alias(alias a)
{
alias Alias = a;
}
// staticReduce should really be in std.typetuple, or
// the soon to arrive std.meta package.
template static
Hi,
Please help rewrite this code to D:
#include
// Peano Arithmetic
struct zero;
template
struct succ {
};
template
struct increment {
using result = succ;
};
template
struct decrement;
template
struct decrement> {
using result = T;
};
template
struct addition;
temp
Ivan Kazmenko:
arr.map !(to !(string))
.join (" ")
.writeln;
I suggest to not put a space before the bang (!), because it's
confusing for me.
Also, "arr.map !(to !(string))" is better written "arr.map!text".
But even better is to use the range formatting of writefln,
a
On Wednesday, 25 March 2015 at 20:09:53 UTC, bearophile wrote:
This is still not very efficient (perhaps the last sorting has
to be stable):
void main() {
import std.stdio, std.algorithm, std.typecons, std.array;
[7, 5, 7, 3, 3, 5, 3, 3, 0, 3, 1, 1, 5, 1, 1, 1, 2, 2, 8,
5, 8, 8]
On Wednesday, 25 March 2015 at 20:17:57 UTC, bearophile wrote:
Ivan Kazmenko:
(1) For me, the name of the function is obscure. Something
like sortBy would be a lot easier to find than schwartzSort.
I've asked to change the name of that function for years. But
Andrei Alexandrescu is a adaman
On Wednesday, 25 March 2015 at 20:09:53 UTC, bearophile wrote:
Dennis Ritchie:
A more effective solution for C ++:
#include
#include
#include
int main() {
using namespace ranges;
auto rng = istream( std::cin )
| to_vector
| action::sort
| view::group_by( st
On Wednesday, 25 March 2015 at 20:02:20 UTC, Ivan Kazmenko wrote:
Will file an issue soon.
Here it is:
https://issues.dlang.org/show_bug.cgi?id=14340
And another one, a 2.067 regression:
https://issues.dlang.org/show_bug.cgi?id=14341
Ivan Kazmenko:
(1) For me, the name of the function is obscure. Something
like sortBy would be a lot easier to find than schwartzSort.
I've asked to change the name of that function for years. But
Andrei Alexandrescu is a adamantly against changing that pet name
he has chosen. This is irrat
Dennis Ritchie:
A more effective solution for C ++:
#include
#include
#include
int main() {
using namespace ranges;
auto rng = istream( std::cin )
| to_vector
| action::sort
| view::group_by( std::equal_to() )
| copy
| action::stab
On Wednesday, 25 March 2015 at 19:32:43 UTC, Dennis Ritchie wrote:
On Wednesday, 25 March 2015 at 19:01:43 UTC, bearophile wrote:
One solution:
Thanks.
On Wednesday, 25 March 2015 at 19:03:27 UTC, bearophile wrote:
But calling "count" for each item is not efficient (in both C#
and D). If you
On Wednesday, 25 March 2015 at 20:02:20 UTC, Ivan Kazmenko wrote:
(2) The documentation says it is more efficient than the first
version in the number of comparisons (verbose lambda with plain
sort) [1], but I don't get how it is possible: unless we know
than (not pred1(a,b)) and (not !pred1(a,
On Wednesday, 25 March 2015 at 19:01:43 UTC, bearophile wrote:
One solution:
Thanks.
On Wednesday, 25 March 2015 at 19:03:27 UTC, bearophile wrote:
But calling "count" for each item is not efficient (in both C#
and D). If your array is largish, then you need a more
efficient solution.
A mo
Ali Çehreli:
Do you know the story about groupBy?
It's a long messy story. Look for it with another name, like
chunkBy or something like that.
Bye,
bearophile
On 03/25/2015 12:01 PM, bearophile wrote:
bearophile
Do you know the story about groupBy? I see it in the documentation but
my git head does not have it:
http://dlang.org/phobos/std_algorithm_iteration.html#.groupBy
Ali
.schwartzSort!(x => tuple(-arr.count!(y => y == x), x))
But calling "count" for each item is not efficient (in both C#
and D). If your array is largish, then you need a more efficient
solution.
Bye,
bearophile
Dennis Ritchie:
int[] arr = { 7, 5, 7, 3, 3, 5, 3, 3, 0, 3, 1, 1, 5, 1,
1, 1, 2, 2, 8, 5, 8, 8 };
Console.WriteLine(string.Join(" ",
arr.OrderByDescending(x => arr.Count(y => y == x)).ThenBy(x =>
x)));
// prints 1 1 1 1 1 3 3 3 3 3 5 5 5 5 8 8 8 2 2 7 7 0
One solutio
Hi,
Can you please tell how to rewrite this code to D?
using System;
using System.Linq;
class Sort
{
static void Main()
{
int[] arr = { 7, 5, 7, 3, 3, 5, 3, 3, 0, 3, 1, 1, 5, 1,
1, 1, 2, 2, 8, 5, 8, 8 };
Console.WriteLine(string.Join(" ",
arr.OrderByDescending(x => arr.C
On Thursday, 12 March 2015 at 21:41:07 UTC, Ali Çehreli wrote:
On 03/12/2015 01:19 PM, Namespace wrote:
> On Thursday, 12 March 2015 at 18:57:51 UTC, Ali Çehreli wrote:
>> On 03/12/2015 06:01 AM, ayush wrote:
>>
>> > Is D a lot like c++ ?
>>
>> I came to D from C++. I remember the following bein
On 03/12/2015 01:19 PM, Namespace wrote:
> On Thursday, 12 March 2015 at 18:57:51 UTC, Ali Çehreli wrote:
>> On 03/12/2015 06:01 AM, ayush wrote:
>>
>> > Is D a lot like c++ ?
>>
>> I came to D from C++. I remember the following being notable
differences:
>>
>> - In D, classes have reference se
On Thursday, 12 March 2015 at 18:57:51 UTC, Ali Çehreli wrote:
On 03/12/2015 06:01 AM, ayush wrote:
> Is D a lot like c++ ?
I came to D from C++. I remember the following being notable
differences:
- In D, classes have reference semantics. I quickly realized
that this is not an issue becaus
On Thursday, 12 March 2015 at 18:57:51 UTC, Ali Çehreli wrote:
If you are a mortal like myself, you may find out years later
that you are still at the midway point. Happened to me several
times when I was learning C++. :)
О, yeah.
On 03/12/2015 06:01 AM, ayush wrote:
> Is D a lot like c++ ?
I came to D from C++. I remember the following being notable differences:
- In D, classes have reference semantics. I quickly realized that this
is not an issue because so many of my C++ types were
hand-reference-typified :p by this
1 - 100 of 216 matches
Mail list logo