On 04/21/2014 09:22 PM, Taylor Hillegeist wrote:
> Question though? why doesn't canFind() work on statically
> allocated arrays?
That's an issue all of face from time to time. (Happened to me again
last week. :) )
The reason is, algorithms like canFind work with input ranges and
fixed-length
On Monday, 21 April 2014 at 08:26:49 UTC, monarch_dodra wrote:
The two "key" points here, first, is to avoid using appender.
Second, instead of having two buffer: "" and "**\n",
and two do two "slice copies", to only have 1 buffer "
*", and to do 1 slice copy, and a single '\n' w
On Tuesday, 22 April 2014 at 03:57:33 UTC, Timothee Cour via
Digitalmars-d-learn wrote:
you can use stuff.canFind(2)
but sometimes it'd be more convenient to have the other way
around (UFCS
chains etc);
how about:
bool isIn(T,T2...)(T needle, T2 haystack)
if(__traits(compiles,T.init==T2[0].i
you can use stuff.canFind(2)
but sometimes it'd be more convenient to have the other way around (UFCS
chains etc);
how about:
bool isIn(T,T2...)(T needle, T2 haystack)
if(__traits(compiles,T.init==T2[0].init)){
foreach(e;haystack){
if(needle==e) return true;
}
return false;
}
unittest{
So I find myself Doing this kind of thing very frequently. I have
a Array of Somethings and i want to see if "something specific"
is inside the array. I wrote a template for it. but is this the
best way to do this kind of thing. I feel like it doesn't help
with readability. Is there a better wa
does that work?
string escapeD(string a){
import std.array:replace;
return `r"`~a.replace(`"`,`" "\"" r"`)~`"`;
}
On Sun, Apr 20, 2014 at 11:14 AM, monarch_dodra via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com> wrote:
> On Sunday, 20 April 2014 at 17:55:25 UTC, Ellery Newcomer wrote:
https://issues.dlang.org/show_bug.cgi?id=12611
Bye,
bearophile
On Mon, 21 Apr 2014 07:49:03 -0400, bearophile
wrote:
In this case I am not sure about bug reports, so I ask here.
In this program the first loop doesn't compile, giving a nice error:
test.d(3,5): Error: index type 'ubyte' cannot cover index range 0..300
If you comment out the first loop,
On Sat, 19 Apr 2014 20:51:49 -0400, David Held wrote:
On 4/19/2014 5:35 PM, David Held wrote:
interface Foo { }
class Bar : Foo
{
override string toString() pure const { return "Bar"; }
}
void main()
{
Foo foo = new Bar;
foo.toString();
}
To make things more interesting, con
On Sat, 19 Apr 2014 20:45:50 -0400, Adam D. Ruppe
wrote:
On Sunday, 20 April 2014 at 00:35:30 UTC, David Held wrote:
Since all implementations of an interface must derive from Object
That's not true. They can also come from IUnknown or a C++ interface.
This is also not true. Only interfa
For the second loop one possible alternative behavour is to
refuse a ubyte index and accept only a size_t index if it loops
on a dynamic array.
Another alternative is: the i variable can go from 0 to 255,
then go up to the modulus of the remaining indexes, and then
stop.
In this program the a
In this case I am not sure about bug reports, so I ask here.
In this program the first loop doesn't compile, giving a nice
error:
test.d(3,5): Error: index type 'ubyte' cannot cover index range
0..300
If you comment out the first loop, the second compiles and runs,
but it seems to go in an
On Monday, 21 April 2014 at 00:11:14 UTC, Jay Norwood wrote:
So this printDiamonde2b example had the fastest time of the
solutions, and had similar times on all three builds. The ldc2
compiler build is performing best in most examples on ubuntu.
void printDiamonde2b(in uint N)
{
uint N2 =
13 matches
Mail list logo