OS minimum version

2015-09-21 Thread ponce via Digitalmars-d-learn
1. What is the minimum Windows version required by programs 
created with DMD?


2. What is the minimum Windows version required by programs 
created with LDC?


3. What is the minimum OS X version required by programs created 
with LDC?


You would believe such information would be easy to find, but 
it's not.


Re: OS minimum version

2015-09-21 Thread Jack Stouffer via Digitalmars-d-learn

On Monday, 21 September 2015 at 12:47:39 UTC, ponce wrote:
3. What is the minimum OS X version required by programs 
created with LDC?


Tiger x86 version, I believe.


Cameleon: Stricter Alternative Implementation of VariantN

2015-09-21 Thread Nordlöw via Digitalmars-d-learn
Because I'm not satisfied with the current state of 
memory-layout-flexibility/pureness/safeness/nogc/nothrow-ness of 
`VariantN` I've hacked together a lightweight version of 
`VariantN`, I currently call `Cameleon`.


The code is here:

https://github.com/nordlow/justd/blob/master/cameleon.d

Its currently limited to my specific needs (strings and 
value-types) through


https://github.com/nordlow/justd/blob/master/cameleon.d#L5
https://github.com/nordlow/justd/blob/master/cameleon.d#L35

because it's hard to decrypt the inner `OpID`-workings of 
`VariantN`.


Questions:

- Is the logic of opAssign and get ok for string?
- How does the inner workings of the GC harmonize with my calls 
to `memcpy` in `opAssign()` here


https://github.com/nordlow/justd/blob/master/cameleon.d#L80
https://github.com/nordlow/justd/blob/master/cameleon.d#L107

and my zeroing of the internal data buffer in `clear()` here

https://github.com/nordlow/justd/blob/master/cameleon.d#L143

?

- Do I have to call some GC-logic in order to make the GC aware 
of the new string-reference in `opAssign`?


- Is this logic for `char[]` different from `(immutable char)[]`?
- And what do I need to think about if I allow classes as members?


Re: foreach automoatic counter?

2015-09-21 Thread cym13 via Digitalmars-d-learn
On Monday, 21 September 2015 at 22:24:22 UTC, French Football 
wrote:

On Monday, 21 September 2015 at 19:23:38 UTC, cym13 wrote:
On Monday, 21 September 2015 at 16:32:25 UTC, French Football 
wrote:

[...]


I had to look into phobos sources 
(/usr/include/dlang/dmd/std/containers/dlist.d) to find a 
unittest, and judging from it it seems inserting in the middle 
of a DList just wasn't taken seriously.


[...]


Thankyou!

But wow... talk about pulling teeth...


Such a unittest should normally be automatically included in 
online documentation when generating it, I don't know they were 
an exception...


Re: Building basic gtkd,opengl application

2015-09-21 Thread Michał via Digitalmars-d-learn

It turns out it was caused by a bug in the gtkd.
Thanks to Mike Wey already fixed.

My minimal working code if somebody was intrested.



Re: foreach automoatic counter?

2015-09-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 21, 2015 15:38:38 French Football via Digitalmars-d-learn 
wrote:
> Going through a book on coding in D,
> http://ddili.org/ders/d.en/foreach.html , I find the following
> very useful feature:
>
> When two names are specified in the names section [with a plain
> array], they represent an automatic counter and the value of the
> element, respectively:
>  foreach (i, element; array) {
>  writeln(i, ": ", element);
>  }
>
> I understand that foreach is built on top of a for loop... I'm
> just wondering why I can't access the automatic counter from a
> doubly linked list, or an associative array, or some range? It's
> pretty common for me to have to rewrite foreach loops to be for
> loops when I get to the bottom and realize I need to know where
> in the sequence I am...

It's an index, not a counter. In the case of an array, it's what's used to
access each element. In the case of an AA, it has no index. It's a set of
unordered key-value pairs. So, if you did

foreach(i, element; aa) {}

what you're really getting is the key and value, not an index and its
corresponding element.

foreach(key, value; aa) {}

would make more sense in that case, but it's merely a change in name. The
types and what they represent are the same regardless.

In the case of an input range, it doesn't have any kind of index. It's just
a list of elements that keep getting popped off in order to iterate through
them.  And whether any kind of index would even make sense would depend on
what the range represents. In the cases where it would make sense, the range
is probably a random-access range, in which case, you can use indices
explicitly if you want. In general though, if you want a counter for the
range that you're indexing, then you can use lockstep to wrap the range, and
then when you use it in foreach, you get the count and the element:

http://dlang.org/phobos/std_range.html#.lockstep

- Jonathan M Davis



Can't seem to alias BinaryHeap and use heapify

2015-09-21 Thread Enjoys Math via Digitalmars-d-learn


I've got:
alias ProgramResultsQueue(O,I) = 
BinaryHeap!(Array!(Results!(O,I)), compareResults);


outside the class ProgramOptimizer.  Inside the class I have:

ProgramResultsQueue!(O,I) programResultsQ = 
heapify!(compareResults, 
Array!(Results!(O,I)))(Array!(Results!(O,I)), 0);


at class scope (not in a function or ctor).

Error:
cannot pass type Array!(Results(int,float)) as a function 
argument.  When I add () to Array!(Results!(O,I)) I get some 
weird error in the library that can't be helped either.


Please guide me!


Re: OS minimum version

2015-09-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 21, 2015 20:47:09 anonymous via Digitalmars-d-learn wrote:
> On Monday 21 September 2015 14:47, ponce wrote:
>
> > 1. What is the minimum Windows version required by programs
> > created with DMD?
>
> http://dlang.org/dmd-windows.html says: "Windows XP or later, 32 or 64 bit".

Then that page needs to be fixe. Windows XP is not supported and hasn't been
since before Microsoft dropped support for it. Officially, we support
Windows 7 and newer:

http://forum.dlang.org/post/ktfgps$2ghh$1...@digitalmars.com

- Jonathan M Davis



Re: Can't seem to alias BinaryHeap and use heapify

2015-09-21 Thread Ali Çehreli via Digitalmars-d-learn

It is much more efficient if you can show the problem in minimal code. :)

Here is minimal code that demonstrates the problem:

import std.container;

struct Results(O, I)
{}

bool compareResults(O, I)(Results!(O, I) lhs, Results!(O, I) rhs)
{
return lhs == rhs;
}

alias ProgramResultsQueue(O,I) =
BinaryHeap!(Array!(Results!(O,I)), compareResults);

class ProgramOptimizer(O, I)
{
ProgramResultsQueue!(O,I) programResultsQ =
heapify!(compareResults, 
Array!(Results!(O,I)))(Array!(Results!(O,I)),

0);
}

void main()
{
auto p = new ProgramOptimizer!(int, float);
}

On 09/21/2015 04:37 PM, Enjoys Math wrote:
>
> I've got:
> alias ProgramResultsQueue(O,I) = BinaryHeap!(Array!(Results!(O,I)),
> compareResults);
>
> outside the class ProgramOptimizer.  Inside the class I have:
>
> ProgramResultsQueue!(O,I) programResultsQ = heapify!(compareResults,
> Array!(Results!(O,I)))(Array!(Results!(O,I)), 0);
>
> at class scope (not in a function or ctor).

You cannot execute code inside the body of a class other than simple 
initialization of members when it's possible to do so at compile time. 
In general, members are initialized in the constructor.


> Error:
> cannot pass type Array!(Results(int,float)) as a function argument.

You are passing 'types' but heapify's function parameter takes a storage 
and an initial size:


  http://dlang.org/phobos/std_container_binaryheap.html#.heapify

(Types cannot be function arguments anyway.)

> When I add () to Array!(Results!(O,I)) I get some weird error in the
> library that can't be helped either.
>
> Please guide me!

The following at least compiles:

import std.container;

struct Results(O, I)
{}

bool compareResults(O, I)(Results!(O, I) lhs, Results!(O, I) rhs)
{
return lhs == rhs;
}

alias ProgramResultsQueue(O,I) =
BinaryHeap!(Array!(Results!(O,I)), compareResults);

class ProgramOptimizer(O, I)
{
Array!(Results!(O, I)) store;
ProgramResultsQueue!(O,I) programResultsQ;

this()
{
programResultsQ =
heapify!(compareResults, Array!(Results!(O,I)))(store, 100);
}
}

void main()
{
auto p = new ProgramOptimizer!(int, float);
}

Ali



Re: Why are static arrays not ranges?

2015-09-21 Thread jmh530 via Digitalmars-d-learn

On Monday, 21 September 2015 at 20:33:10 UTC, Jack Stouffer wrote:


That's ridiculous. Do I have to wrap my static arrays in 
structs to get range primitives?


Is there an actual reason for this?


I had done basically the same thing. Below is my naive 
implementation.


import std.traits;
import std.range;
import std.array : array;
import std.stdio : writeln;
import std.algorithm : map;

struct hybrid_array(T : U[N], U, size_t N)
if ( isStaticArray!T )
{
T static_array;
private auto _length = static_array.length;
auto domain = iota(0, static_array.length);

this(T x)
{
static_array = x;
}

@property bool empty()
{
return domain.empty;
}

@property size_t length()
{
return _length;
}

@property U front()
{
assert(!empty);
return static_array[domain.front];
}

void popFront()
{
assert(!empty);
domain.popFront;
_length--;
}

@property hybrid_array save()
{
return this;
}

@property U back()
{
assert(!empty);
return static_array[domain.back];
}

void popBack()
{
assert(!empty);
domain.popBack;
_length++;
}

U opIndex(size_t val)
{
assert(!empty);
return static_array[domain[val]];
}
}

void main()
{
int[5] x = [0, 10, 2, 6, 1];
//auto squares = map!(a => a * a)(x); //doesn't work

auto range = iota(0, x.length).array;

alias h_array = hybrid_array!(int[5]);
auto y = h_array(x);

writeln( isRandomAccessRange!(typeof(y)) );

auto squares = map!(a => a * a)(y); //success, does work
writeln(squares);
}


Re: Why are static arrays not ranges?

2015-09-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 21, 2015 20:46:51 Jack Stouffer via Digitalmars-d-learn 
wrote:
> On Monday, 21 September 2015 at 20:39:55 UTC, Jesse Phillips
> wrote:
> > A static array has a constant length, so it is not possible to
> > popFront on a static array.
> >
> > Making a dynamic array from it is easy, just slice it with []:
> >
> >  pragma(msg, isInputRange!(typeof(a[])));
> >  pragma(msg, isForwardRange!(typeof(a[])));
> >  pragma(msg, isRandomAccessRange!(typeof(a[])));
>
> Thanks for all of the replies. I was under the impression that
> the slicer allocated GC, but some tests show that's not true.

All that slicing a static array does is give you a dynamic array which
refers to the static array. It's then the same as any other dynamic array
except that you have to make sure that it doesn't continue to refer to the
static array after the static array no longer exists, and it's guaranteed to
have no extra capacity, so if you do append to it, it's guaranteed to
reallocate, whereas one allocated via new may or may not have extra
capacity, depending on what's been done with that dynamic array and any
other dynamic arrays were sliced from it and thus may or may not have to be
reallocated when it's appended to. Similarly, slicing malloced memory gets
you a dynamic array which refers to malloced memory and thus has no extra
capacity, and you have to be careful to not still have it around when the
malloced memory is freed.

I would suggest that you read this

http://dlang.org/d-array-article.html

and possibly watch this

http://dconf.org/2015/talks/davis.html

- Jonathan M Davis



Re: foreach automoatic counter?

2015-09-21 Thread French Football via Digitalmars-d-learn

On Monday, 21 September 2015 at 19:23:38 UTC, cym13 wrote:
On Monday, 21 September 2015 at 16:32:25 UTC, French Football 
wrote:

[...]


I had to look into phobos sources 
(/usr/include/dlang/dmd/std/containers/dlist.d) to find a 
unittest, and judging from it it seems inserting in the middle 
of a DList just wasn't taken seriously.


[...]


Thankyou!

But wow... talk about pulling teeth...


Re: foreach automoatic counter?

2015-09-21 Thread Justin Whear via Digitalmars-d-learn
On Mon, 21 Sep 2015 15:38:38 +, French Football wrote:

> Going through a book on coding in D,
> http://ddili.org/ders/d.en/foreach.html , I find the following very
> useful feature:
> 
> When two names are specified in the names section [with a plain array],
> they represent an automatic counter and the value of the element,
> respectively:
>  foreach (i, element; array) {
>  writeln(i, ": ", element);
>  }
> 
> I understand that foreach is built on top of a for loop... I'm just
> wondering why I can't access the automatic counter from a doubly linked
> list, or an associative array, or some range? It's pretty common for me
> to have to rewrite foreach loops to be for loops when I get to the
> bottom and realize I need to know where in the sequence I am...

With an associative array the foreach becomes:

foreach (key, value; aa)

For arbitrary ranges you can use std.range.enumerate like this:

foreach (i, element; someRange.enumerate)


foreach automoatic counter?

2015-09-21 Thread French Football via Digitalmars-d-learn
Going through a book on coding in D, 
http://ddili.org/ders/d.en/foreach.html , I find the following 
very useful feature:


When two names are specified in the names section [with a plain 
array], they represent an automatic counter and the value of the 
element, respectively:

foreach (i, element; array) {
writeln(i, ": ", element);
}

I understand that foreach is built on top of a for loop... I'm 
just wondering why I can't access the automatic counter from a 
doubly linked list, or an associative array, or some range? It's 
pretty common for me to have to rewrite foreach loops to be for 
loops when I get to the bottom and realize I need to know where 
in the sequence I am...


Re: foreach automoatic counter?

2015-09-21 Thread cym13 via Digitalmars-d-learn
On Monday, 21 September 2015 at 15:38:40 UTC, French Football 
wrote:
Going through a book on coding in D, 
http://ddili.org/ders/d.en/foreach.html , I find the following 
very useful feature:


When two names are specified in the names section [with a plain 
array], they represent an automatic counter and the value of 
the element, respectively:

foreach (i, element; array) {
writeln(i, ": ", element);
}

I understand that foreach is built on top of a for loop... I'm 
just wondering why I can't access the automatic counter from a 
doubly linked list, or an associative array, or some range? 
It's pretty common for me to have to rewrite foreach loops to 
be for loops when I get to the bottom and realize I need to 
know where in the sequence I am...


That's because this isn't really a counter. It makes more sens if 
you think of it as:


foreach (key, value ; array) {
...
}

In the case of an array, the key to access directly a value is 
its index, and the array is read in its natural order so the 
'key' part acts as a counter.  If array is an associative array 
instead of an array, then you get the key and value as well.


If you want a counter, you want to look at std.range.enumerate() 
which takes a range and returns a tuple (counter, element). The 
following example demonstrates the two usages with associative 
arrays:


void main(string[] args)
{
import std.stdio;
import std.range;

bool[int] aa = [0:true, 1:true, 2:false];

writeln("Get keys and values from an AA");
foreach (key, value ; aa) {
writeln(key, ": ", value);
}
writeln;

writeln("Get a counter and the key of an AA");
foreach (count, key ; aa.byKey.enumerate) {
writeln("count: ", count, " key: ", key, " value: ", 
aa[key]);

}
}

Note that contrary to languages such as PHP, D's associative 
arrays are unordered so you can't use this counter as an index.




Do users need to install VS runtime redistributable if linking with Microsoft linker?

2015-09-21 Thread ponce via Digitalmars-d-learn

All in the title.

DMD 64-bit links with the VS linker.
Do users need to install the VS redistributable libraries?


Re: Building basic gtkd,opengl application

2015-09-21 Thread Michał via Digitalmars-d-learn

So no idea how to make basic gtk/opengl application working?


Re: Building basic gtkd,opengl application

2015-09-21 Thread Michał via Digitalmars-d-learn

On Monday, 21 September 2015 at 18:07:27 UTC, Ali Çehreli wrote:

Does that work?


Yes and clear output there.
I have tried some basic examples of gtkd and they seems to work. 
GLArea has some problems.


Re: Building basic gtkd,opengl application

2015-09-21 Thread Ali Çehreli via Digitalmars-d-learn

On 09/21/2015 10:59 AM, Michał wrote:

So no idea how to make basic gtk/opengl application working?


With no experience at all, copying an example without opengl from a 
basic and incomplete Turkish gtkd tutorial[1]:


import gtk.Window;
import gtk.Main;

int main(string[] args)
{
Main.init(args);
auto pencere = new Window("deneme");
pencere.show();
Main.run;

return 0;
}

Does that work?

Ali

[1] http://ddili.org/ders/gtkd/merhaba_gtkd.html



Re: Building basic gtkd,opengl application

2015-09-21 Thread Michał via Digitalmars-d-learn

On Monday, 21 September 2015 at 18:08:15 UTC, bachmeier wrote:

On Monday, 21 September 2015 at 17:59:17 UTC, Michał wrote:

So no idea how to make basic gtk/opengl application working?


The project has its own forum if you haven't already posted 
there: http://forum.gtkd.org/


I didn't. I will try there.
Thanks for help.


Re: Building basic gtkd,opengl application

2015-09-21 Thread bachmeier via Digitalmars-d-learn

On Monday, 21 September 2015 at 17:59:17 UTC, Michał wrote:

So no idea how to make basic gtk/opengl application working?


The project has its own forum if you haven't already posted 
there: http://forum.gtkd.org/


Re: foreach automoatic counter?

2015-09-21 Thread French Football via Digitalmars-d-learn

On Monday, 21 September 2015 at 15:54:06 UTC, Justin Whear wrote:



On Monday, 21 September 2015 at 15:58:12 UTC, cym13 wrote:




Thankyou! .enumerate lets me iterate over a container with a 
counter.


--Related tangential question... If I have a DList, how do I 
insert into the middle of it? I'm trying .insertAfter but it 
wants a range and apparently I can only slice an entire Dlist 
with [].


Re: Tried release build got ICE, does anyone have a clue what might cause this?

2015-09-21 Thread Kagamin via Digitalmars-d-learn

On Friday, 18 September 2015 at 22:54:43 UTC, Random D user wrote:

I get:

tym = x1d
Internal error: backend\cgxmm.c 547

Does anyone have a clue what might trigger this?


https://issues.dlang.org/show_bug.cgi?id=7951
https://issues.dlang.org/show_bug.cgi?id=12377

On Saturday, 19 September 2015 at 21:48:25 UTC, Random D user 
wrote:
Assertion failure: 'type->ty != Tstruct || ((TypeStruct 
*)type)->sym == this' on line 957 in file 'struct.c'


Ugh...
It really seems like D starts to break down once your code 
grows beyond toy program size. A bit frustrating...


https://issues.dlang.org/show_bug.cgi?id=15092
https://issues.dlang.org/show_bug.cgi?id=11260


Re: tkd not linking

2015-09-21 Thread karabuta via Digitalmars-d-learn
On Tuesday, 15 September 2015 at 17:46:42 UTC, Adam D. Ruppe 
wrote:

On Tuesday, 15 September 2015 at 17:37:40 UTC, karabuta wrote:

Just incase, I have install version 8.6 of the Tcl/Tk libraries


Did you get the development version?

sudo apt-get install tk-dev

or possibly

sudo apt-get install tk8.6-dev

should do it. I'm not actually sure if that's required for this 
(I've never used it) but it might be.


What is the problem. And how is tcltk different from tkd in 
the first place?


tkd is just a D wrapper for the library.




Thanks Adam, sudo apt-get install tk-dev worked. Hurray! lets 
start GUI programming in D!


Re: Why are static arrays not ranges?

2015-09-21 Thread cym13 via Digitalmars-d-learn

On Monday, 21 September 2015 at 20:33:10 UTC, Jack Stouffer wrote:

import std.range;

void main() {
int[6] a = [1, 2, 3, 4, 5, 6];

pragma(msg, isInputRange!(typeof(a)));
pragma(msg, isForwardRange!(typeof(a)));
pragma(msg, isRandomAccessRange!(typeof(a)));
}

$ dmd -run test.d
false
false
false

That's ridiculous. Do I have to wrap my static arrays in 
structs to get range primitives?


Is there an actual reason for this?


For an element of explanation see my answer at a similar question 
here:


http://forum.dlang.org/post/xdhuberedpjuxydbw...@forum.dlang.org


Why are static arrays not ranges?

2015-09-21 Thread Jack Stouffer via Digitalmars-d-learn

import std.range;

void main() {
int[6] a = [1, 2, 3, 4, 5, 6];

pragma(msg, isInputRange!(typeof(a)));
pragma(msg, isForwardRange!(typeof(a)));
pragma(msg, isRandomAccessRange!(typeof(a)));
}

$ dmd -run test.d
false
false
false

That's ridiculous. Do I have to wrap my static arrays in structs 
to get range primitives?


Is there an actual reason for this?


Re: Why are static arrays not ranges?

2015-09-21 Thread Jesse Phillips via Digitalmars-d-learn

On Monday, 21 September 2015 at 20:33:10 UTC, Jack Stouffer wrote:

import std.range;

void main() {
int[6] a = [1, 2, 3, 4, 5, 6];

pragma(msg, isInputRange!(typeof(a)));
pragma(msg, isForwardRange!(typeof(a)));
pragma(msg, isRandomAccessRange!(typeof(a)));
}

$ dmd -run test.d
false
false
false

That's ridiculous. Do I have to wrap my static arrays in 
structs to get range primitives?


Is there an actual reason for this?


A static array has a constant length, so it is not possible to 
popFront on a static array.


Making a dynamic array from it is easy, just slice it with []:

 pragma(msg, isInputRange!(typeof(a[])));
 pragma(msg, isForwardRange!(typeof(a[])));
 pragma(msg, isRandomAccessRange!(typeof(a[])));


Re: Why are static arrays not ranges?

2015-09-21 Thread Adam D. Ruppe via Digitalmars-d-learn

On Monday, 21 September 2015 at 20:33:10 UTC, Jack Stouffer wrote:

pragma(msg, isInputRange!(typeof(a)));


try:

 pragma(msg, isInputRange!(typeof(a[])));

Notice the addition of the [] after the a. That's the slicing 
operator and it will yield a range.



Is there an actual reason for this?


A static array is a container; a block of memory. A range is a 
*view* into a container. When you popFront a range, you aren't 
modifying the underlying memory, you are just advancing the view 
to the next element. popFront of a static array is impossible 
anyway due to the immutability of its length, but even if it was 
possible, advancing your view to the next item should not 
actually delete the item if at all possible.


Dynamic arrays are actually similar btw, the underlying container 
for them is just hidden from view because the garbage collector 
manages it, so all you see is the slice (view/range).


Re: Why are static arrays not ranges?

2015-09-21 Thread anonymous via Digitalmars-d-learn
On Monday 21 September 2015 22:33, Jack Stouffer wrote:

> import std.range;
> 
> void main() {
>  int[6] a = [1, 2, 3, 4, 5, 6];
> 
>  pragma(msg, isInputRange!(typeof(a)));
>  pragma(msg, isForwardRange!(typeof(a)));
>  pragma(msg, isRandomAccessRange!(typeof(a)));
> }
> 
> $ dmd -run test.d
> false
> false
> false
> 
> That's ridiculous. Do I have to wrap my static arrays in structs 
> to get range primitives?

You can just slice them: `a[]` is an `int[]` which is a range.

> Is there an actual reason for this?

How would popFront work on an `int[6]`? popFront can't change the type, but 
it must remove an element.


Re: Why are static arrays not ranges?

2015-09-21 Thread Jack Stouffer via Digitalmars-d-learn
On Monday, 21 September 2015 at 20:39:55 UTC, Jesse Phillips 
wrote:
A static array has a constant length, so it is not possible to 
popFront on a static array.


Making a dynamic array from it is easy, just slice it with []:

 pragma(msg, isInputRange!(typeof(a[])));
 pragma(msg, isForwardRange!(typeof(a[])));
 pragma(msg, isRandomAccessRange!(typeof(a[])));


Thanks for all of the replies. I was under the impression that 
the slicer allocated GC, but some tests show that's not true.


Re: foreach automoatic counter?

2015-09-21 Thread cym13 via Digitalmars-d-learn
On Monday, 21 September 2015 at 16:32:25 UTC, French Football 
wrote:
On Monday, 21 September 2015 at 15:54:06 UTC, Justin Whear 
wrote:



On Monday, 21 September 2015 at 15:58:12 UTC, cym13 wrote:




Thankyou! .enumerate lets me iterate over a container with a 
counter.


--Related tangential question... If I have a DList, how do I 
insert into the middle of it? I'm trying .insertAfter but it 
wants a range and apparently I can only slice an entire Dlist 
with [].


I had to look into phobos sources 
(/usr/include/dlang/dmd/std/containers/dlist.d) to find a 
unittest, and judging from it it seems inserting in the middle of 
a DList just wasn't taken seriously.


@safe unittest
{
import std.algorithm : equal;

auto dl = DList!string(["a", "b", "d"]);
dl.insertAfter(dl[], "e"); // insert at the end
assert(equal(dl[], ["a", "b", "d", "e"]));
auto dlr = dl[];
dlr.popBack(); dlr.popBack();
dl.insertAfter(dlr, "c"); // insert after "b"
assert(equal(dl[], ["a", "b", "c", "d", "e"]));
}

There is however a nicer method using std.ranges:

void main(string[] args) {
import std.stdio;
import std.range;
import std.container: DList;

auto list = DList!int([1, 2, 3, 5]);

list.insertBefore(list[].drop(3), 4);

foreach(n ; list)
writeln(n);
}

I hope this is helpful.



Re: OS minimum version

2015-09-21 Thread Jacob Carlborg via Digitalmars-d-learn

On 2015-09-21 14:47, ponce wrote:

1. What is the minimum Windows version required by programs created with
DMD?

2. What is the minimum Windows version required by programs created with
LDC?


I'm guessing Windows XP for both LDC and DMD. Windows is pretty good at 
backwards compatibility.



3. What is the minimum OS X version required by programs created with LDC?


For LDC, OS X 10.7 (Lion). For DMD, 10.6.


You would believe such information would be easy to find, but it's not.


Took me 10 seconds [1].

[1] http://wiki.dlang.org/LDC#OS_X

--
/Jacob Carlborg


Re: OS minimum version

2015-09-21 Thread anonymous via Digitalmars-d-learn
On Monday 21 September 2015 14:47, ponce wrote:

> 1. What is the minimum Windows version required by programs 
> created with DMD?

http://dlang.org/dmd-windows.html says: "Windows XP or later, 32 or 64 bit".


Re: OS minimum version

2015-09-21 Thread ponce via Digitalmars-d-learn

On Monday, 21 September 2015 at 18:47:10 UTC, anonymous wrote:

On Monday 21 September 2015 14:47, ponce wrote:

1. What is the minimum Windows version required by programs 
created with DMD?


http://dlang.org/dmd-windows.html says: "Windows XP or later, 
32 or 64 bit".


Thanks to all.