How can i get the number of items which are currently hold in a
DList?
pgtkda:
How can i get the number of items which are currently hold in a
DList?
Try (walkLength is from std.range):
mydList[].walkLength
Bye,
bearophile
On Wednesday, 9 July 2014 at 07:43:57 UTC, Ali Çehreli wrote:
Phobos algorithms use ranges. The following is what I've come
up with very quickly:
Thx
On Thursday, 10 July 2014 at 12:12:20 UTC, Marc Schütz wrote:
On Wednesday, 9 July 2014 at 15:09:08 UTC, Chris wrote:
On Wednesday, 9 July 2014 at 15:00:25 UTC, seany wrote:
I apologize many times for this question, may be this had
already been answered somewhere, but considering today the
las
On Wednesday, 9 July 2014 at 07:43:57 UTC, Ali Çehreli wrote:
Ali
This
https://github.com/nordlow/justd/blob/master/random_ex.d
is what I have so far. Does this look ok to you?
Question: Can I somehow avoid the duplication of logic in
- auto ref randInPlace(R)(R x) @safe if (hasAssignableEl
On Thursday, 10 July 2014 at 15:36:53 UTC, francesco cattoglio
wrote:
A code I'm working on stops working and starts printing an
infinite loop of
core.exception.InvalidMemoryOperationError
to the command line output. The code is quite complex and the
bug seems to present itself almost in random
On 7/11/14, 4:46 AM, bearophile wrote:
pgtkda:
How can i get the number of items which are currently hold in a DList?
Try (walkLength is from std.range):
mydList[].walkLength
Bye,
bearophile
So the doubly linked list doesn't know it's length? That seems a bit
inefficient...
Ary Borenszweig:
So the doubly linked list doesn't know it's length? That seems
a bit inefficient...
Have you tried to compile mydList.length or mydList[].length? If
both don't compile, then you have to walk the items.
Walking the items is not efficient, but:
- Linked lists are very uncommo
On Fri, Jul 11, 2014 at 10:23:58AM -0300, Ary Borenszweig via
Digitalmars-d-learn wrote:
> On 7/11/14, 4:46 AM, bearophile wrote:
> >pgtkda:
> >
> >>How can i get the number of items which are currently hold in a
> >>DList?
> >
> >Try (walkLength is from std.range):
> >
> >mydList[].walkLength
> >
Tried to compile on linux, got this error message (I guess I can
fix it):
dmd -c textgen.d
textgen.d(36): Error: cannot implicitly convert expression
("DMDScript fatal runtime error: ") of type string to char[]
textgen.d(36): Error: cannot implicitly convert expression (0) of
type int to char[
On Friday, 11 July 2014 at 11:43:44 UTC, Joakim wrote:
On Thursday, 10 July 2014 at 15:36:53 UTC, francesco cattoglio
wrote:
A code I'm working on stops working and starts printing an
infinite loop of
core.exception.InvalidMemoryOperationError
to the command line output. The code is quite compl
Is there a trait to check if a type is a
- value type (struct, static array, etc)
- reference type (class, dynamic array, string, etc)
?
On Friday, 11 July 2014 at 16:10:31 UTC, Nordlöw wrote:
Is there a trait to check if a type is a
- value type (struct, static array, etc)
- reference type (class, dynamic array, string, etc)
?
There's http://dlang.org/phobos/std_traits.html#hasIndirections
Note that structs and static arrays
On 07/11/2014 03:38 AM, "Nordlöw" wrote:
> https://github.com/nordlow/justd/blob/master/random_ex.d
>
> is what I have so far. Does this look ok to you?
The following seems redundant because the other isFloatingPoint!E
version uses the default arguments 0 and 1 anyway.
auto ref randInPlace(E)
@nogc
void main(string[] args)
{
immutable(char)[] s1 = "hello";
immutable(int)[] a1 = [1, 2];
}
Why does the s1 not throw an error, but the a1 does? As far as I
can tell, they're both immutable arrays.
Error is: "Error: array literal @nogc function main may cause GC
allocation"
It
On Friday, 11 July 2014 at 20:02:32 UTC, Weasel wrote:
Why does the s1 not throw an error, but the a1 does?
Strings don't allocate upon use whereas all other arrays do
unless you specifically mark it as static - immutability isn't
considered here (I think because the part of the compiler that
Key difference is that type of string literal is
immutable(char)[] so it is perfectly legal to keep it in binary
text segment. Type of array literal is just T[] (int[] here) and
you can possibly mutate their elements. Because of this each
assignment of array literal needs to allocate a new copy
On 07/11/2014 10:39 PM, Dicebot wrote:
Key difference is that type of string literal is immutable(char)[] so it
is perfectly legal to keep it in binary text segment. Type of array
literal is just T[] (int[] here) and you can possibly mutate their
elements. Because of this each assignment of array
http://forum.dlang.org/thread/pxotrowaqcenrpnnw...@forum.dlang.org
On Friday, 11 July 2014 at 21:02:30 UTC, Timon Gehr wrote:
He is allocating an immutable(int)[] here. There is no reason
why it should allocate unless providing different addresses for
different runs of the code is considered a feature, as the
literal has a compile-time known value. It's just t
On Thursday, 10 July 2014 at 19:33:15 UTC, simendsjo wrote:
On 07/10/2014 06:05 PM, Alexandre wrote:
I have a string X and I need to insert a char in that string...
auto X = "100";
And I need to inser a ',' in position 3 of this string..., I
try to use
the array.insertInPlace, bu
I'm new to D. I've been using C since it was a baby and C++ back
when it was only a pre-compiler for c. So, I may just be stuck
thinking in C land.
The issue is I am attempting to use the version(unittest)
feature. However the compiler pukes up the error below. I'm sure
it's something easy en
On 12/07/2014 5:08 p.m., dysmondad wrote:
I'm new to D. I've been using C since it was a baby and C++ back when it
was only a pre-compiler for c. So, I may just be stuck thinking in C land.
The issue is I am attempting to use the version(unittest) feature.
However the compiler pukes up the error
On 07/11/2014 10:08 PM, dysmondad wrote:
> class Velocity
> {
[...]
> ref Velocity opOpAssign(string op) ( in float multiplier )
Unrelated to your question, you want to return just Velocity there.
Unlike C++, classes are reference types in D. So, Velocity itself is
essentially a Velocit
How Can I Print Raw Binary Into The Console?
I Have Variable Of Type ubyte which equals 0b011 How Can I Get
The Variable To Print Out As 011
On 07/11/2014 10:56 PM, Sean Campbell wrote:
> How Can I Print Raw Binary Into The Console?
Taking a step back, a D program prints to stdout, not console. However,
in most cases a D program's output ends up on the console when it is
started in a console.
So, one can print any byte value to t
26 matches
Mail list logo