On Thursday, 22 October 2015 at 15:10:58 UTC, pineapple wrote:
What does if(isIntegral!T) do? It looks like it would verify
that the template type is a discrete number?
It doesn't verify, but filters: you can have several templates
with the same name, when filter doesn't match, compiler tries
On Thursday, 22 October 2015 at 13:58:56 UTC, Adam D. Ruppe wrote:
D's templates are easy (you actually used one in there, the
Generator is one!)
Try this:
import std.concurrency;
Generator!T sequence(T)(T i){
return new Generator!T({
yield(i);
while(i > 1){
On Thursday, 22 October 2015 at 13:53:33 UTC, pineapple wrote:
I'm just starting to hammer D's very pleasant syntax into my
head. After "Hello world", the first thing I do when learning
any language is to write a simple program which generates and
outputs the Collatz sequence for an arbitrary
I'm just starting to hammer D's very pleasant syntax into my
head. After "Hello world", the first thing I do when learning any
language is to write a simple program which generates and outputs
the Collatz sequence for an arbitrary number. (I also like to
golf it.) This is what I wrote in D:
On Thursday, 22 October 2015 at 13:53:33 UTC, pineapple wrote:
import std.concurrency;
Generator!int sequence(int i){
return new Generator!int({
yield(i);
while(i > 1){
yield(i = (i % 2) ? (i * 3 + 1) : (i >> 1));
}
});
}
Which can be used like so:
On Thursday, 22 October 2015 at 14:36:52 UTC, John Colvin wrote:
Using ranges instead of threads or fibers, slightly
over-engineered to show off features:
What does if(isIntegral!T) do? It looks like it would verify that
the template type is a discrete number? If I were to create my
own
On Thursday, 22 October 2015 at 15:10:58 UTC, pineapple wrote:
On Thursday, 22 October 2015 at 14:36:52 UTC, John Colvin wrote:
Using ranges instead of threads or fibers, slightly
over-engineered to show off features:
What does if(isIntegral!T) do? It looks like it would verify
that the