On Tuesday, 16 October 2018 at 21:12:39 UTC, welkam wrote:
On Tuesday, 16 October 2018 at 20:58:54 UTC, Jabari Zakiya
wrote:
And they could be modded to catch semantics like this and
produce faster code.
Its hard to prove that you will only write 1 or 0 in the array
and even if you write such
On Tuesday, 16 October 2018 at 20:58:54 UTC, Jabari Zakiya wrote:
And they could be modded to catch semantics like this and
produce faster code.
Its hard to prove that you will only write 1 or 0 in the array
and even if you write such pass it wont fire very often. So
slower compile times for
On Tuesday, 16 October 2018 at 20:38:24 UTC, welkam wrote:
On Tuesday, 16 October 2018 at 17:57:23 UTC, Jabari Zakiya
wrote:
This is the exact same behavior I found with the Nim compiler
too.
Well Nim compiler is more like translator. It translates Nim
code to c or c++. Since gcc was responsi
On Tuesday, 16 October 2018 at 17:57:23 UTC, Jabari Zakiya wrote:
This is the exact same behavior I found with the Nim compiler
too.
Well Nim compiler is more like translator. It translates Nim code
to c or c++. Since gcc was responsible for optimizations and
instruction selection it would be
On Tuesday, 16 October 2018 at 07:09:05 UTC, Vijay Nayar wrote:
On Monday, 15 October 2018 at 22:17:57 UTC, Jabari Zakiya wrote:
$ dub build --compiler=ldc2 -b=release && echo "30" |
./twinprimes
Enter integer number:
threads = 8
each thread segment is [1 x 65536] bytes array
twinprime
On Tuesday, 16 October 2018 at 16:57:12 UTC, welkam wrote:
So I run profiler and 97% of time is spent in void twinsSieve
function and hotspots are seg[k] = seg[k] | 1; lines. Since
seg[k] can only be 1 or 0 I removed that or operation. And the
results are. Queue the drum-roll... 5% slower.
I
On Tuesday, 16 October 2018 at 07:09:05 UTC, Vijay Nayar wrote:
D has multiple compilers, but for the speed of the finished
binary, LDC2 is generally recommended. I used version 1.11.0.
https://github.com/ldc-developers/ldc/releases/tag/v1.11.0
I was using DUB to manage the project, but to b
So I run profiler and 97% of time is spent in void twinsSieve
function and hotspots are seg[k] = seg[k] | 1; lines. Since
seg[k] can only be 1 or 0 I removed that or operation. And the
results are. Queue the drum-roll... 5% slower.
I thought that all of my studying was getting somewhere. That
On Monday, 15 October 2018 at 22:17:57 UTC, Jabari Zakiya wrote:
$ dub build --compiler=ldc2 -b=release && echo "30" |
./twinprimes
Enter integer number:
threads = 8
each thread segment is [1 x 65536] bytes array
twinprime candidates = 175324676; resgroups = 1298702
each 135 threads has
$ dub build --compiler=ldc2 -b=release && echo "30" |
./twinprimes
Enter integer number:
threads = 8
each thread segment is [1 x 65536] bytes array
twinprime candidates = 175324676; resgroups = 1298702
each 135 threads has nextp[2 x 5566] array
setup time = 1 ms, 864 μs, and 7 hnsecs
perf
I don't actually understand the underlying algorithm, but I at
least understand the flow of the program and the structure.
The algorithm utilized depends heavily on using shared memory
access, which can be done in D, but I definitely wouldn't call
it idiomatic. In D, message passing is prefer
On Sunday, 14 October 2018 at 10:51:11 UTC, Vijay Nayar wrote:
Once I get the bugs out, I'm curious to see if any performance
differences crop up. There's the theory that says they should
be the same, and then there's the practice.
I don't actually understand the underlying algorithm, but I a
On Sunday, 14 October 2018 at 10:51:11 UTC, Vijay Nayar wrote:
But as previous posters have said, the code is not really very
different between Nim and D. Most of it is array manipulation
and arithmetic operations, and not many of the features of
either D or Nim are very different. Both turn
On Saturday, 13 October 2018 at 19:04:48 UTC, Jabari Zakiya wrote:
On Saturday, 13 October 2018 at 18:31:57 UTC, Vijay Nayar wrote:
On Saturday, 13 October 2018 at 18:14:20 UTC, Vijay Nayar
wrote:
On Saturday, 13 October 2018 at 18:05:45 UTC, Jabari Zakiya
wrote:
It may be also running into a
On Saturday, 13 October 2018 at 18:31:57 UTC, Vijay Nayar wrote:
On Saturday, 13 October 2018 at 18:14:20 UTC, Vijay Nayar wrote:
On Saturday, 13 October 2018 at 18:05:45 UTC, Jabari Zakiya
wrote:
It may be also running into a hard time limit imposed on
compilation that Nim had/has that preve
On Saturday, 13 October 2018 at 18:14:20 UTC, Vijay Nayar wrote:
On Saturday, 13 October 2018 at 18:05:45 UTC, Jabari Zakiya
wrote:
It may be also running into a hard time limit imposed on
compilation that Nim had/has that prevented my code from
initially compiling. I'm generating a lot of PG
On Saturday, 13 October 2018 at 18:14:20 UTC, Vijay Nayar wrote:
On Saturday, 13 October 2018 at 18:05:45 UTC, Jabari Zakiya
wrote:
It may be also running into a hard time limit imposed on
compilation that Nim had/has that prevented my code from
initially compiling. I'm generating a lot of PG
On Saturday, 13 October 2018 at 18:05:45 UTC, Jabari Zakiya wrote:
It may be also running into a hard time limit imposed on
compilation that Nim had/has that prevented my code from
initially compiling. I'm generating a lot of PG parameter
constants at compile time, and it's doing a lot of num
On Saturday, 13 October 2018 at 17:36:33 UTC, Vijay Nayar wrote:
On Saturday, 13 October 2018 at 15:50:06 UTC, Vijay Nayar wrote:
On Saturday, 13 October 2018 at 15:19:07 UTC, Jabari Zakiya
wrote:
On Saturday, 13 October 2018 at 14:32:33 UTC, welkam wrote:
On Saturday, 13 October 2018 at 09:22:
On Saturday, 13 October 2018 at 15:50:06 UTC, Vijay Nayar wrote:
On Saturday, 13 October 2018 at 15:19:07 UTC, Jabari Zakiya
wrote:
On Saturday, 13 October 2018 at 14:32:33 UTC, welkam wrote:
On Saturday, 13 October 2018 at 09:22:16 UTC, Vijay Nayar
wrote:
[...]
import algorithm
thats all b
On Saturday, 13 October 2018 at 15:19:07 UTC, Jabari Zakiya wrote:
On Saturday, 13 October 2018 at 14:32:33 UTC, welkam wrote:
On Saturday, 13 October 2018 at 09:22:16 UTC, Vijay Nayar
wrote:
[...]
import algorithm
thats all but then it spits out
lib/nim/pure/algorithm.nim(144, 11) Error: i
On Saturday, 13 October 2018 at 14:32:33 UTC, welkam wrote:
On Saturday, 13 October 2018 at 09:22:16 UTC, Vijay Nayar wrote:
I downloaded the reference NIM implementation and got the
latest nim compiler, but I received the following error:
$ nim c --cc:gcc --d:release --threads:on twinprime
On Saturday, 13 October 2018 at 14:32:33 UTC, welkam wrote:
On Saturday, 13 October 2018 at 09:22:16 UTC, Vijay Nayar wrote:
I downloaded the reference NIM implementation and got the
latest nim compiler, but I received the following error:
$ nim c --cc:gcc --d:release --threads:on twinprime
On Saturday, 13 October 2018 at 09:22:16 UTC, Vijay Nayar wrote:
I downloaded the reference NIM implementation and got the
latest nim compiler, but I received the following error:
$ nim c --cc:gcc --d:release --threads:on twinprimes_ssoz.nim
twinprimes_ssoz.nim(74, 11) Error: attempting to
On Friday, 12 October 2018 at 21:08:03 UTC, Jabari Zakiya wrote:
On Friday, 12 October 2018 at 20:05:29 UTC, welkam wrote:
On Friday, 12 October 2018 at 16:19:59 UTC, Jabari Zakiya
wrote:
The real point of the challenge is too see what idiomatic
code...
There is no idiomatic D code. There is
On Friday, 12 October 2018 at 20:05:29 UTC, welkam wrote:
On Friday, 12 October 2018 at 16:19:59 UTC, Jabari Zakiya wrote:
The real point of the challenge is too see what idiomatic
code...
There is no idiomatic D code. There is only better
implementations.
D doesnt tell you how to write
On Friday, 12 October 2018 at 16:19:59 UTC, Jabari Zakiya wrote:
The real point of the challenge is too see what idiomatic
code...
There is no idiomatic D code. There is only better
implementations.
D doesnt tell you how to write your code. It gives you many tools
and you choose which
On Friday, 12 October 2018 at 16:19:59 UTC, Jabari Zakiya wrote:
Hmm,I don't think what you're saying about similar
output|performance with other languages is empirically correct,
but it's really not the point of the challenge.
Thats why godbolt exists.
c++ and Rust
https:
uages is empirically correct,
but it's really not the point of the challenge.
The real point of the challenge is too see what idiomatic code,
written for performance, using the best resources that the
language provides, will produce compared, to the Nim version.
It's not to see what a lin
On Wednesday, 10 October 2018 at 16:15:56 UTC, Jabari Zakiya
wrote:
What I am requesting here is for a person(s) who is an "expert"
(very good) to create a very fast D version, using whatever
tricks it has to maximize performance.
I would like to include in my paper a good comparison of
vario
On 10/11/2018 10:14 AM, Jabari Zakiya wrote:
> Ok, hopefully this will work for everyone. Try this link:
>
> https://mega.nz/#!yJxUEQgK!MY9dwjiWheE8tACtEeS0szduIvdBjiyTn4O6mMD_aZw
Thank you. That worked just fine. I clicked the Download link and the
pdf was saved on my end. :)
Ali
On Thursday, 11 October 2018 at 16:13:17 UTC, Jabari Zakiya wrote:
On Thursday, 11 October 2018 at 14:49:54 UTC, Carl Sturtivant
wrote:
On Thursday, 11 October 2018 at 13:26:19 UTC, Jabari Zakiyth
wrote:
On Thursday, 11 October 2018 at 05:11:20 UTC, Ali Çehreli
wrote:
[...]
What country are
On Thursday, 11 October 2018 at 14:49:54 UTC, Carl Sturtivant
wrote:
On Thursday, 11 October 2018 at 13:26:19 UTC, Jabari Zakiyth
wrote:
On Thursday, 11 October 2018 at 05:11:20 UTC, Ali Çehreli
wrote:
[...]
What country are you trying to get access from, because I know
people in the US have
On Thursday, 11 October 2018 at 13:26:19 UTC, Jabari Zakiyth
wrote:
On Thursday, 11 October 2018 at 05:11:20 UTC, Ali Çehreli wrote:
[...]
What country are you trying to get access from, because I know
people in the US have gotten the papers from those link, for
free and without an account.
On Thursday, 11 October 2018 at 05:11:20 UTC, Ali Çehreli wrote:
On 10/10/2018 07:52 PM, Jabari Zakiyth wrote:
> On Wednesday, 10 October 2018 at 22:25:17 UTC, Neia Neutuladh
wrote:
>> On 10/10/2018 03:05 PM, Jabari Zakiya wrote:
>>>
https://www.scribd.com/doc/228155369/The-Segmented-Sieve-of-Za
On 10/10/2018 07:52 PM, Jabari Zakiyth wrote:
> On Wednesday, 10 October 2018 at 22:25:17 UTC, Neia Neutuladh wrote:
>> On 10/10/2018 03:05 PM, Jabari Zakiya wrote:
>>> https://www.scribd.com/doc/228155369/The-Segmented-Sieve-of-Zakiya-SSoZ
>>
>> It would be great if you could provide a link to a
On Thursday, 11 October 2018 at 00:22:10 UTC, tide wrote:
On Wednesday, 10 October 2018 at 16:15:56 UTC, Jabari Zakiya
wrote:
I would like to include in my paper a good comparison of
various implementations in different compiled languages
(C/C++, D, Nim, etc) to show how it performs with each.
On Wednesday, 10 October 2018 at 22:25:17 UTC, Neia Neutuladh
wrote:
On 10/10/2018 03:05 PM, Jabari Zakiya wrote:
https://www.scribd.com/doc/228155369/The-Segmented-Sieve-of-Zakiya-SSoZ
It would be great if you could provide a link to a freely
downloadable version of this.
You can download
On Wednesday, 10 October 2018 at 16:15:56 UTC, Jabari Zakiya
wrote:
I would like to include in my paper a good comparison of
various implementations in different compiled languages (C/C++,
D, Nim, etc) to show how it performs with each.
If you want help with your paper, possibly some kind of d
On 10/10/2018 03:05 PM, Jabari Zakiya wrote:
https://www.scribd.com/doc/228155369/The-Segmented-Sieve-of-Zakiya-SSoZ
It would be great if you could provide a link to a freely downloadable
version of this.
On Wednesday, 10 October 2018 at 20:43:01 UTC, Kagamin wrote:
On Wednesday, 10 October 2018 at 16:15:56 UTC, Jabari Zakiya
wrote:
https://gist.github.com/jzakiya/6c7e1868bd749a6b1add62e3e3b2341e
As i understand, main thread preallocates global memory and
tracks it, and other threads don't tra
On Wednesday, 10 October 2018 at 16:15:56 UTC, Jabari Zakiya
wrote:
https://gist.github.com/jzakiya/6c7e1868bd749a6b1add62e3e3b2341e
As i understand, main thread preallocates global memory and
tracks it, and other threads don't track it?
On Wednesday, 10 October 2018 at 16:15:56 UTC, Jabari Zakiya
wrote:
[...]
Looking forward to this :)
Hi.
I hope this is the right place to request this, if not please
tell me a better one.
I had looked at D, and played with it some circa 2010~2012, but
time and life took my priorities away. But I'm still interested
in learning different languages, but there are so many more now
it's hard t
On Friday, 16 February 2018 at 09:44:27 UTC, aberba wrote:
D has tone of features and library solutions. When you
encounter a problem, how do you approach solving it in code?
1. Do you first write it in idiomatic D style or a more general
approach before porting to idiomatic D?
Like always,
On Friday, 16 February 2018 at 09:44:27 UTC, aberba wrote:
1. Do you first write it in idiomatic D style or a more general
approach before porting to idiomatic D?
In micro-level, it's usually fairly idiomatic from get-go.
Usually no heap allocations at inner loops, for-looping, static
variabl
On Friday, 16 February 2018 at 09:44:27 UTC, aberba wrote:
D has tone of features and library solutions. When you
encounter a problem, how do you approach solving it in code?
1. Do you first write it in idiomatic D style or a more general
approach before porting to idiomatic D?
As idiomatic
I don't write much D code, but here are my answers for _any_
language.
On Friday, 16 February 2018 at 09:44:27 UTC, aberba wrote:
D has tone of features and library solutions. When you
encounter a problem, how do you approach solving it in code?
1. Do you first write it in idiomatic D style o
On 16/02/2018 9:44 AM, aberba wrote:
D has tone of features and library solutions. When you encounter a
problem, how do you approach solving it in code?
1. Do you first write it in idiomatic D style or a more general approach
before porting to idiomatic D?
2. Do you find yourself mostly roll
D has tone of features and library solutions. When you encounter
a problem, how do you approach solving it in code?
1. Do you first write it in idiomatic D style or a more general
approach before porting to idiomatic D?
2. Do you find yourself mostly rolling out your own
implementation first
I found funny (from my point of view) challenge in Russian Stack
Overflow.
Any language accepted.
You need to make the loop
for (int x=0; x<3; ++x) {}
endless.
Rules:
- you can't modify the loop's code itself;
- you can't modify the loop's variable inside the body of
On 6 October 2016 at 01:07, Jonathan M Davis via Digitalmars-d
wrote:
> On Thursday, October 06, 2016 00:38:54 Manu via Digitalmars-d wrote:
>> I thought there was a distinction between typetuple and alias? Some
>> expression can be captured by a typetuple, but not by alias?
>> There must be a rea
On Thursday, October 06, 2016 00:38:54 Manu via Digitalmars-d wrote:
> I thought there was a distinction between typetuple and alias? Some
> expression can be captured by a typetuple, but not by alias?
> There must be a reason for that horrible and prolific pattern "(T...)
> if(T.length == 1) { ...
On 5 October 2016 at 19:45, Jonathan M Davis via Digitalmars-d
wrote:
> On Wednesday, October 05, 2016 09:24:56 John Colvin via Digitalmars-d wrote:
>> > It _is_ however recommended to use __traits(getMember, T,
>> > member) over manually building it with strings with something
>> > like T.stringo
On Wednesday, October 05, 2016 09:24:56 John Colvin via Digitalmars-d wrote:
> > It _is_ however recommended to use __traits(getMember, T,
> > member) over manually building it with strings with something
> > like T.stringof ~ "." ~ member, because the string manipulation
> > falls about in corner
On Wednesday, 5 October 2016 at 02:15:13 UTC, Jonathan M Davis
wrote:
On Wednesday, October 05, 2016 11:20:44 Manu via Digitalmars-d
wrote:
> While you're at it, might I suggest also adding
> std.traits.isProperty?
>
> Something like:
> template isProperty(T, string member)
> {
>
> import st
On Wednesday, 5 October 2016 at 02:15:13 UTC, Jonathan M Davis
wrote:
The AliasSeq muck is there because for some reason you can't
alias the result of __traits, so doing something like
alias sym = __traits(getMember, T, member);
isn't legal. So, this has nothing to do with a recommendation
of
On Wednesday, October 05, 2016 11:20:44 Manu via Digitalmars-d wrote:
> > While you're at it, might I suggest also adding std.traits.isProperty?
> >
> > Something like:
> > template isProperty(T, string member)
> > {
> >
> > import std.meta : AliasSeq;
> > import std.traits : FunctionTypeOf;
>
On 4 October 2016 at 22:48, Manu wrote:
> On 4 October 2016 at 14:40, Jonathan M Davis via Digitalmars-d
> wrote:
>> On Tuesday, October 04, 2016 14:24:59 Manu via Digitalmars-d wrote:
>>> On 4 October 2016 at 12:30, Jonathan M Davis via Digitalmars-d
>>>
>>> wrote:
>>> > On Tuesday, October 04,
On 4 October 2016 at 14:40, Jonathan M Davis via Digitalmars-d
wrote:
> On Tuesday, October 04, 2016 14:24:59 Manu via Digitalmars-d wrote:
>> On 4 October 2016 at 12:30, Jonathan M Davis via Digitalmars-d
>>
>> wrote:
>> > On Tuesday, October 04, 2016 11:13:36 Manu via Digitalmars-d wrote:
>> >>
On 4 October 2016 at 14:40, Jonathan M Davis via Digitalmars-d
wrote:
> [...]
> For that matter, even testing whether something is a variable is
> surprisingly difficult.
True story! I've written that one before... I spent ages trying to get it right!
When people say D is highly complex, these ar
On Tuesday, October 04, 2016 14:24:59 Manu via Digitalmars-d wrote:
> On 4 October 2016 at 12:30, Jonathan M Davis via Digitalmars-d
>
> wrote:
> > On Tuesday, October 04, 2016 11:13:36 Manu via Digitalmars-d wrote:
> >> I'm feeling John's solution is a little bit simpler. But nice work,
> >> than
On 4 October 2016 at 12:30, Jonathan M Davis via Digitalmars-d
wrote:
> On Tuesday, October 04, 2016 11:13:36 Manu via Digitalmars-d wrote:
>> I'm feeling John's solution is a little bit simpler. But nice work, thanks!
>
> So, it is. LOL. I'd actually glanced over that post while I was in the
> mi
On Tuesday, October 04, 2016 11:13:36 Manu via Digitalmars-d wrote:
> I'm feeling John's solution is a little bit simpler. But nice work, thanks!
So, it is. LOL. I'd actually glanced over that post while I was in the
middle of getting my version to work, and I read it too quickly, because I
unders
On 4 October 2016 at 05:01, Jonathan M Davis via Digitalmars-d
wrote:
> On Monday, October 03, 2016 11:13:52 Jonathan M Davis via Digitalmars-d wrote:
>> template isStaticMember(T, string member)
>> {
>> static if (!__traits(hasMember, T, member))
>> enum bool isStaticMember = false;
>
On 4 October 2016 at 00:25, John Colvin via Digitalmars-d
wrote:
> On Monday, 3 October 2016 at 13:19:19 UTC, Manu wrote:
>>
>> Fill in the blank...
>> I'm having a really hard time with this. I've made it work with a
>> mountain of code, and I want to see what others come up with...
>
>
> templat
On Monday, October 03, 2016 11:13:52 Jonathan M Davis via Digitalmars-d wrote:
> template isStaticMember(T, string member)
> {
> static if (!__traits(hasMember, T, member))
> enum bool isStaticMember = false;
> else
> {
> import std.meta : AliasSeq;
> import std.
On 10/03/2016 07:41 AM, Seb wrote:
On Monday, 3 October 2016 at 13:19:19 UTC, Manu wrote:
Fill in the blank...
I'm having a really hard time with this. I've made it work with a
mountain of code, and I want to see what others come up with...
If you succeed, put it in std.traits!
Recommend, use
On Monday, October 03, 2016 08:38:22 Jonathan M Davis via Digitalmars-d wrote:
> On Monday, October 03, 2016 23:19:19 Manu via Digitalmars-d wrote:
> > Fill in the blank...
> > I'm having a really hard time with this. I've made it work with a
> > mountain of code, and I want to see what others come
On Monday, October 03, 2016 23:19:19 Manu via Digitalmars-d wrote:
> Fill in the blank...
> I'm having a really hard time with this. I've made it work with a
> mountain of code, and I want to see what others come up with...
It's certainly possible that this misses something, but it passes all of
y
On Monday, October 03, 2016 23:19:19 Manu via Digitalmars-d wrote:
> Fill in the blank...
> I'm having a really hard time with this. I've made it work with a
> mountain of code, and I want to see what others come up with...
>
> If you succeed, put it in std.traits!
>
> Recommend, use latest DMD nig
On Monday, 3 October 2016 at 13:19:19 UTC, Manu wrote:
Fill in the blank...
I'm having a really hard time with this. I've made it work with
a
mountain of code, and I want to see what others come up with...
If you succeed, put it in std.traits!
Recommend, use latest DMD nightly. I find differe
On 3 October 2016 at 23:48, Manu wrote:
> On 3 October 2016 at 23:41, Manu wrote:
>> I'm finding this rather annoying:
>>
>> struct S
>> {
>> static @property int p() { return 10; }
>> }
>>
>> pragma(msg, typeof(&S.p)); // prints: int function() @property
>> pragma(msg, is(typeof(&S.p) == funct
On Monday, 3 October 2016 at 13:19:19 UTC, Manu wrote:
Fill in the blank...
I'm having a really hard time with this. I've made it work with
a
mountain of code, and I want to see what others come up with...
template isStaticMember(T, string member)
{
mixin(`alias mem = T.` ~ member ~ `;`);
On Monday, 3 October 2016 at 13:19:19 UTC, Manu wrote:
Fill in the blank...
I'm having a really hard time with this. I've made it work with
a
mountain of code, and I want to see what others come up with...
[...]
Dere's a typo
static assert( isStaticMember!(S, "iosm"), "!");
Should be iosf
On Monday, 3 October 2016 at 13:41:13 UTC, Manu wrote:
I'm finding this rather annoying:
struct S
{
static @property int p() { return 10; }
}
pragma(msg, typeof(&S.p)); // prints: int function() @property
pragma(msg, is(typeof(&S.p) == function)); // prints: false
It looks like a function...
On 3 October 2016 at 23:50, John Colvin via Digitalmars-d
wrote:
> On Monday, 3 October 2016 at 13:41:13 UTC, Manu wrote:
>>
>> I'm finding this rather annoying:
>>
>> struct S
>> {
>> static @property int p() { return 10; }
>> }
>>
>> pragma(msg, typeof(&S.p)); // prints: int function() @proper
On Monday, 3 October 2016 at 13:50:26 UTC, John Colvin wrote:
The problem is that function pointers in "is" expressions don't
match "function" or "delegate".
static assert (is(void delegate() == delegate)); //passes
static assert (is(void function() == function)); //fails
static assert (is(void
On Monday, 3 October 2016 at 13:41:13 UTC, Manu wrote:
I'm finding this rather annoying:
struct S
{
static @property int p() { return 10; }
}
pragma(msg, typeof(&S.p)); // prints: int function() @property
pragma(msg, is(typeof(&S.p) == function)); // prints: false
It looks like a function...
On 3 October 2016 at 23:41, Manu wrote:
> I'm finding this rather annoying:
>
> struct S
> {
> static @property int p() { return 10; }
> }
>
> pragma(msg, typeof(&S.p)); // prints: int function() @property
> pragma(msg, is(typeof(&S.p) == function)); // prints: false
>
> It looks like a function
On Monday, 3 October 2016 at 13:41:13 UTC, Manu wrote:
I'm finding this rather annoying:
struct S
{
static @property int p() { return 10; }
}
pragma(msg, typeof(&S.p)); // prints: int function() @property
pragma(msg, is(typeof(&S.p) == function)); // prints: false
It looks like a function...
On Monday, 3 October 2016 at 13:19:19 UTC, Manu wrote:
Fill in the blank...
I'm having a really hard time with this. I've made it work with
a
mountain of code, and I want to see what others come up with...
If you succeed, put it in std.traits!
Pretty easy:
template isStaticMember(T, string m
I'm finding this rather annoying:
struct S
{
static @property int p() { return 10; }
}
pragma(msg, typeof(&S.p)); // prints: int function() @property
pragma(msg, is(typeof(&S.p) == function)); // prints: false
It looks like a function... but I can't identify it as a function!
Fill in the blank...
I'm having a really hard time with this. I've made it work with a
mountain of code, and I want to see what others come up with...
If you succeed, put it in std.traits!
Recommend, use latest DMD nightly. I find differences with latest
nightly vs release.
-
would have if r
were sorted. Also, r[0 .. x] contains stuff no greater than
r[x] and r[x + 1 .. $] contains stuff no less than r[x].
The challenge is to implement such a function with fairness: if
several elements are equal to r[pivot], return the index
closest to r.length / 2.
The fu
r than r[x] and r[x + 1
.. $] contains stuff no less than r[x].
The challenge is to implement such a function with fairness: if several
elements are equal to r[pivot], return the index closest to r.length / 2.
The function should be efficient, minimize calls to less and swap, etc.
A variant t
On Sunday 30 August 2015 16:43, rsw0x wrote:
> Is there any reason that closure in this particular example can't
> be created on the stack? Seems a bit weird.
It may be possible to store it on the stack somehow, or as part of the map
struct. I don't know.
The point is, that's not what happens.
On Sunday, 30 August 2015 at 13:36:45 UTC, anonymous wrote:
On Sunday 30 August 2015 12:21, rsw0x wrote:
[...]
I think this shouldn't compile and it only does so because of
issue 14771.
https://issues.dlang.org/show_bug.cgi?id=14771
The delegate in foo uses a local variable and it's retur
On Sunday 30 August 2015 12:21, rsw0x wrote:
> import std.algorithm, std.range;
>
> auto foo(R)(R a, immutable int b)
> {
> return a.map!(x => x + b);
> }
>
> @nogc @safe unittest
> {
> int[3] test = [1,2,3];
>
> assert(test[].foo(3).equal(only(4,5,6)));
> }
>
> does this count?
On Sunday, 30 August 2015 at 11:21:34 UTC, Russel Winder wrote:
On Sun, 2015-08-30 at 10:38 +, John Colvin via
Digitalmars-d wrote:
On Sunday, 30 August 2015 at 10:15:14 UTC, John Colvin wrote:
> [...]
Ok, so now I feel stupid. Not only was the unittest I gave
above broken anyway, I realis
> > }
> >
> > unittest @nogc @safe
> > {
> > int[] test = [1,2,3];
> >
> > assert(test.foo(3).equal(only(4,5,6)));
> > }
> >
> > Challenge: reimplement `foo` such that above unittest will
> > compile. No cheating with malloc
On Sunday, 30 August 2015 at 10:15:14 UTC, John Colvin wrote:
import std.algorithm, std.range;
auto foo(R)(R a, immutable int b)
{
return a.map!(x => x + b);
}
unittest @nogc @safe
{
int[] test = [1,2,3];
assert(test.foo(3).equal(only(4,5,6)));
}
Challenge: reimplement `foo` s
o(3).equal(only(4,5,6)));
}
Challenge: reimplement `foo` such that above unittest will
compile. No cheating with malloc etc. Bonus points if you
don't have to implement a modified version of std.algorithm.map
import std.algorithm, std.range;
auto foo(R)(R a, immutable int b)
{
return
On Sunday, 30 August 2015 at 10:15:14 UTC, John Colvin wrote:
import std.algorithm, std.range;
auto foo(R)(R a, immutable int b)
{
return a.map!(x => x + b);
}
unittest @nogc @safe
{
int[] test = [1,2,3];
assert(test.foo(3).equal(only(4,5,6)));
}
Challenge: reimplement `foo` s
import std.algorithm, std.range;
auto foo(R)(R a, immutable int b)
{
return a.map!(x => x + b);
}
unittest @nogc @safe
{
int[] test = [1,2,3];
assert(test.foo(3).equal(only(4,5,6)));
}
Challenge: reimplement `foo` such that above unittest will
compile. No cheating with malloc
On Tuesday, 21 April 2015 at 13:06:22 UTC, JohnnyK wrote:
On Monday, 20 April 2015 at 19:24:01 UTC, Panke wrote:
On Monday, 20 April 2015 at 18:03:50 UTC, John Colvin wrote:
On Monday, 20 April 2015 at 17:48:17 UTC, Panke wrote:
To measure the columns needed to print a string, you'll need
the
On Monday, 20 April 2015 at 19:24:01 UTC, Panke wrote:
On Monday, 20 April 2015 at 18:03:50 UTC, John Colvin wrote:
On Monday, 20 April 2015 at 17:48:17 UTC, Panke wrote:
To measure the columns needed to print a string, you'll need
the number of graphemes. (d|)?string.length gives you the
numb
On Monday, 20 April 2015 at 19:24:01 UTC, Panke wrote:
On Monday, 20 April 2015 at 18:03:50 UTC, John Colvin wrote:
On Monday, 20 April 2015 at 17:48:17 UTC, Panke wrote:
To measure the columns needed to print a string, you'll need
the number of graphemes. (d|)?string.length gives you the
numb
On Monday, 20 April 2015 at 18:03:50 UTC, John Colvin wrote:
On Monday, 20 April 2015 at 17:48:17 UTC, Panke wrote:
To measure the columns needed to print a string, you'll need
the number of graphemes. (d|)?string.length gives you the
number of code units.
Even that's not really true.
Why?
On Monday, 20 April 2015 at 17:48:17 UTC, Panke wrote:
This can lead to subtle bugs, cf. length of random and e_one.
You have to convert everything to dstring to get the
"expected" result. However, this is not always desirable.
There are three things that you need to be aware of when
handling
1 - 100 of 506 matches
Mail list logo