On Saturday, 7 May 2022 at 02:29:59 UTC, Salih Dincer wrote:
On Friday, 6 May 2022 at 18:04:13 UTC, JG wrote:
```d
//...
struct Adder {
int a;
int opCall(int b) { return a+b; }
}
auto adder(int a) {
auto ret = Adder.init;
ret.a=a;
return ret;
}
void main() {
auto g =
On Friday, 6 May 2022 at 18:04:13 UTC, JG wrote:
```d
//...
struct Adder {
int a;
int opCall(int b) { return a+b; }
}
auto adder(int a) {
auto ret = Adder.init;
ret.a=a;
return ret;
}
void main() {
auto g = adder(5);
g(5).writeln; // 10
auto d = toDelegate!(int,
On Friday, 6 May 2022 at 18:35:40 UTC, Ali Çehreli wrote:
On 5/6/22 11:04, JG wrote:
> [...]
This is a segmentation fault. Reduced:
import std;
[...]
Hi, thanks. That was quite silly. (I was thinking the variable
lives to the end of scope of main but not thinking about that I
am passing
On 5/6/22 11:04, JG wrote:
> This isn't code to be used for anything (just understanding).
This is a segmentation fault. Reduced:
import std;
struct Delegate(A,B) {
B function(void* ptr, A a) f;
void* data;
B opCall(A a) {
return f(data,a);
}
}
auto toDelegate(A,
This isn't code to be used for anything (just understanding).
```d
import std;
struct Delegate(A,B) {
B function(void* ptr, A a) f;
void* data;
B opCall(A a) {
return f(data,a);
}
}
auto toDelegate(A, B,S)(S s) {
static B f(void* ptr, A a) {
return
On Sunday, 13 August 2017 at 06:09:39 UTC, amfvcg wrote:
Hi all,
I'm solving below task:
given container T and value R return sum of R-ranges over T. An
example:
input : T=[1,1,1] R=2
output : [2, 1]
input : T=[1,2,3] R=1
output : [1,2,3]
(see dlang unittests for more examples)
Below c++
On Sunday, 13 August 2017 at 09:56:44 UTC, Johan Engelen wrote:
On Sunday, 13 August 2017 at 09:15:48 UTC, amfvcg wrote:
Change the parameter for this array size to be taken from
stdin and I assume that these optimizations will go away.
This is paramount for all of the testing, examining,
On Sunday, 13 August 2017 at 09:41:39 UTC, Johan Engelen wrote:
On Sunday, 13 August 2017 at 09:08:14 UTC, Petar Kirov
[ZombineDev] wrote:
[...]
[...]
Execution of sum_subranges is already O(1), because the
calculation of the sum is delayed: the return type of the
function is not
On Sunday, 13 August 2017 at 09:15:48 UTC, amfvcg wrote:
Change the parameter for this array size to be taken from stdin
and I assume that these optimizations will go away.
This is paramount for all of the testing, examining, and
comparisons that are discussed in this thread.
Full
On Sunday, 13 August 2017 at 09:08:14 UTC, Petar Kirov
[ZombineDev] wrote:
This instantiation:
sum_subranges(std.range.iota!(int, int).iota(int, int).Result,
uint)
of the following function:
auto sum_subranges(T)(T input, uint range)
{
import std.range : chunks, ElementType, array;
On Sunday, 13 August 2017 at 09:08:14 UTC, Petar Kirov
[ZombineDev] wrote:
There's one especially interesting result:
This instantiation:
sum_subranges(std.range.iota!(int, int).iota(int, int).Result,
uint)
of the following function:
auto sum_subranges(T)(T input, uint range)
{
import
On Sunday, 13 August 2017 at 08:43:29 UTC, amfvcg wrote:
On Sunday, 13 August 2017 at 08:33:53 UTC, Petar Kirov
[ZombineDev] wrote:
With Daniel's latest version (
http://forum.dlang.org/post/mailman.5963.1502612885.31550.digitalmars-d-le...@puremagic.com
)
$ ldc2 -O3 --release
On Sunday, 13 August 2017 at 08:33:53 UTC, Petar Kirov
[ZombineDev] wrote:
With Daniel's latest version (
http://forum.dlang.org/post/mailman.5963.1502612885.31550.digitalmars-d-le...@puremagic.com
)
$ ldc2 -O3 --release sum_subranges2.d
$ ./sum_subranges2
210 ms, 838 μs, and 8 hnsecs
On Sunday, 13 August 2017 at 08:32:50 UTC, amfvcg wrote:
Gives me
5 μs and 2 hnsecs
5000
3 secs, 228 ms, 837 μs, and 4 hnsecs
5000
And you've compiled it with?
Btw. clang for c++ version works worse than gcc (for this case
[112ms vs 180ms]).
DMD64 D Compiler v2.074.1
And this one is awesome :P
http://ideone.com/muehUw
On Sun, Aug 13, 2017 at 10:27 AM, Daniel Kozak wrote:
> this one is even faster than c++:
> http://ideone.com/TRDsOo
>
> On Sun, Aug 13, 2017 at 10:00 AM, Daniel Kozak wrote:
>
>> my second version on ldc
On Sunday, 13 August 2017 at 08:29:30 UTC, Petar Kirov
[ZombineDev] wrote:
On Sunday, 13 August 2017 at 08:13:56 UTC, amfvcg wrote:
On Sunday, 13 August 2017 at 08:00:53 UTC, Daniel Kozak wrote:
my second version on ldc takes 380ms and c++ version on same
compiler (clang), takes 350ms, so it
Gives me
5 μs and 2 hnsecs
5000
3 secs, 228 ms, 837 μs, and 4 hnsecs
5000
And you've compiled it with?
Btw. clang for c++ version works worse than gcc (for this case
[112ms vs 180ms]).
On Sunday, 13 August 2017 at 08:13:56 UTC, amfvcg wrote:
On Sunday, 13 August 2017 at 08:00:53 UTC, Daniel Kozak wrote:
my second version on ldc takes 380ms and c++ version on same
compiler (clang), takes 350ms, so it seems to be almost same
Ok, on ideone (ldc 1.1.0) it timeouts, on dpaste
On Sunday, 13 August 2017 at 08:13:56 UTC, amfvcg wrote:
On Sunday, 13 August 2017 at 08:00:53 UTC, Daniel Kozak wrote:
my second version on ldc takes 380ms and c++ version on same
compiler (clang), takes 350ms, so it seems to be almost same
Ok, on ideone (ldc 1.1.0) it timeouts, on dpaste
this one is even faster than c++:
http://ideone.com/TRDsOo
On Sun, Aug 13, 2017 at 10:00 AM, Daniel Kozak wrote:
> my second version on ldc takes 380ms and c++ version on same compiler
> (clang), takes 350ms, so it seems to be almost same
>
> On Sun, Aug 13, 2017 at 9:51 AM,
On Sunday, 13 August 2017 at 08:00:53 UTC, Daniel Kozak wrote:
my second version on ldc takes 380ms and c++ version on same
compiler (clang), takes 350ms, so it seems to be almost same
Ok, on ideone (ldc 1.1.0) it timeouts, on dpaste (ldc 0.12.0) it
gets killed.
What version are you using?
my second version on ldc takes 380ms and c++ version on same compiler
(clang), takes 350ms, so it seems to be almost same
On Sun, Aug 13, 2017 at 9:51 AM, amfvcg via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com> wrote:
> On Sunday, 13 August 2017 at 07:30:32 UTC, Daniel Kozak wrote:
>
On Sunday, 13 August 2017 at 07:30:32 UTC, Daniel Kozak wrote:
Here is more D idiomatic way:
import std.stdio : writeln;
import std.algorithm.comparison: min;
import std.algorithm.iteration: sum;
import core.time: MonoTime, Duration;
auto sum_subranges(T)(T input, uint range)
{
import
Here is more D idiomatic way:
import std.stdio : writeln;
import std.algorithm.comparison: min;
import std.algorithm.iteration: sum;
import core.time: MonoTime, Duration;
auto sum_subranges(T)(T input, uint range)
{
import std.array : array;
import std.range : chunks, ElementType;
this works ok for me with ldc compiler, gdc does not work on my arch
machine so I can not do comparsion to your c++ versin (clang does not work
with your c++ code)
import std.stdio : writeln;
import std.algorithm.comparison: min;
import std.algorithm.iteration: sum;
import core.time: MonoTime,
On Sunday, 13 August 2017 at 06:09:39 UTC, amfvcg wrote:
Hi all,
I'm solving below task:
Well, for one thing, you are preallocating in C++ code but not in
D.
On my machine, your version of the code completes in 3.175
seconds. Changing it a little reduces it to 0.420s:
T[] result =
On Sunday, 13 August 2017 at 06:09:39 UTC, amfvcg wrote:
Hi all,
I'm solving below task:
given container T and value R return sum of R-ranges over T. An
example:
input : T=[1,1,1] R=2
output : [2, 1]
input : T=[1,2,3] R=1
output : [1,2,3]
(see dlang unittests for more examples)
Below c++
On 13/08/2017 7:09 AM, amfvcg wrote:
Hi all,
I'm solving below task:
given container T and value R return sum of R-ranges over T. An example:
input : T=[1,1,1] R=2
output : [2, 1]
input : T=[1,2,3] R=1
output : [1,2,3]
(see dlang unittests for more examples)
Below c++ code compiled with
Hi all,
I'm solving below task:
given container T and value R return sum of R-ranges over T. An
example:
input : T=[1,1,1] R=2
output : [2, 1]
input : T=[1,2,3] R=1
output : [1,2,3]
(see dlang unittests for more examples)
Below c++ code compiled with g++-5.4.0 -O2 -std=c++14 runs on my
Here's a minimal example:
http://pastebin.com/mJDwGDbb
Is this a bug in Pegged?
Nothing seems to fix it.
On 2/5/2015 4:53 PM, Entity325 wrote:
On Thursday, 5 February 2015 at 07:23:15 UTC, drug wrote:
Look at this
https://github.com/drug007/geoviewer/blob/master/src/sdlapp.d
I used here SDL and OpenGL and it worked. Ctor of SDLApp creates SDL
window with OpenGL context, may be it helps.
Tested
On 05.02.2015 10:53, Entity325 wrote:
On Thursday, 5 February 2015 at 07:23:15 UTC, drug wrote:
Look at this
https://github.com/drug007/geoviewer/blob/master/src/sdlapp.d
I used here SDL and OpenGL and it worked. Ctor of SDLApp creates SDL
window with OpenGL context, may be it helps.
Tested
Aldacron and I have determined that I'm doing something weird
with the imports between gl.d and gl3.d, the functions I'm trying
to access are deprecated so the problem is less that they aren't
loading and more that I can see them at all.
I will see how much I can strip away and still reproduce the
problem. If I find the cause before then, I'll be sure to report
back here.
I am having a problem which is similar in appearance to the OP's,
but it does not seem to be similar in function. When I try to
execute any of the Gl functions in the (protected)
DerelictGL3.gl.loadSymbols function, I get an access violation.
Checking for null reveals that the functions are
On Thursday, 5 February 2015 at 06:07:34 UTC, Entity325 wrote:
I will see how much I can strip away and still reproduce the
problem. If I find the cause before then, I'll be sure to
report back here.
I don't know if this is relevant, but while stripping down my
code, I discovered that
On 05.02.2015 09:57, Entity325 wrote:
On Thursday, 5 February 2015 at 06:07:34 UTC, Entity325 wrote:
I will see how much I can strip away and still reproduce the problem.
If I find the cause before then, I'll be sure to report back here.
I don't know if this is relevant, but while stripping
On Thursday, 5 February 2015 at 07:23:15 UTC, drug wrote:
Look at this
https://github.com/drug007/geoviewer/blob/master/src/sdlapp.d
I used here SDL and OpenGL and it worked. Ctor of SDLApp
creates SDL window with OpenGL context, may be it helps.
Tested your code. Symbols still not being
On Thursday, 5 February 2015 at 01:51:05 UTC, Entity325 wrote:
I am having a problem which is similar in appearance to the
OP's, but it does not seem to be similar in function. When I
try to execute any of the Gl functions in the (protected)
DerelictGL3.gl.loadSymbols function, I get an access
I cannot figure out what is wrong with this code and why i keep
getting object.error access violation. the code is simple
tutorial code for SDL and OpenGL what am i doing wrong (the
access violation seems to be with glGenBuffers)
The Code
import std.stdio;
import derelict.opengl3.gl3;
import
Can you try to add DerelictGL3.reload(); after
SDL_GL_CreateContext ?
Sean Campbell:
I cannot figure out what is wrong with this code and why i keep
getting object.error access violation. the code is simple
tutorial code for SDL and OpenGL what am i doing wrong (the
access violation seems to be with glGenBuffers)
I don't know where your problem is, but you
On Friday, 4 July 2014 at 08:02:59 UTC, Misu wrote:
Can you try to add DerelictGL3.reload(); after
SDL_GL_CreateContext ?
yes this solved the problem. however why? is it a problem with
the SDL binding?
On Friday, 4 July 2014 at 09:39:49 UTC, Sean Campbell wrote:
On Friday, 4 July 2014 at 08:02:59 UTC, Misu wrote:
Can you try to add DerelictGL3.reload(); after
SDL_GL_CreateContext ?
yes this solved the problem. however why? is it a problem with
the SDL binding?
No.
On 7/4/2014 6:39 PM, Sean Campbell wrote:
On Friday, 4 July 2014 at 08:02:59 UTC, Misu wrote:
Can you try to add DerelictGL3.reload(); after SDL_GL_CreateContext ?
yes this solved the problem. however why? is it a problem with the SDL
binding?
OpenGL on Windows requires a context be created
Hey everyone, I'm new to D so bare with me please. I've been
trying to figure out what's up with the strange forward refernce
errors the compiler (DMD 2.060) is giving me. Here's a code
snippet that's generating a forward reference error:
public class AliasTestClass(alias func)
{
On 2012-10-14, 14:28, Martin wrote:
Hey everyone, I'm new to D so bare with me please. I've been trying to
figure out what's up with the strange forward refernce errors the
compiler (DMD 2.060) is giving me. Here's a code snippet that's
generating a forward reference error:
public class
On Sunday, 14 October 2012 at 12:58:24 UTC, Simen Kjaeraas wrote:
On 2012-10-14, 14:28, Martin wrote:
Hey everyone, I'm new to D so bare with me please. I've been
trying to figure out what's up with the strange forward
refernce errors the compiler (DMD 2.060) is giving me. Here's
a code
): Range violation on the
line with the arrow.
What am I doing wrong ?
You could also try:
foreach_reverse(i, ref f; array) { f.x = i; }
--
Marco
.
What am I doing wrong ?
index is array.length-1.
writeln();
foreach(Foo f; array) { write(f.x);}
}
throws core.exception.RangeError@bug(8): Range violation on the line
with the arrow.
What am I doing wrong ?
--
Dmitry Olshansky
1; i--) { array[i].x = i; }
writeln();
foreach(Foo f; array) { write(f.x);}
}
throws core.exception.RangeError@bug(8): Range violation on the line
with the arrow.
What am I doing wrong ?
You set i to the array length of 10 but the array index is zero based so
the last item in the array
On Sunday, 22 April 2012 at 21:50:32 UTC, Dmitry Olshansky wrote:
Omagad, thank you, too much Java is bd for your brains.
53 matches
Mail list logo