> But those list-like data structures probably can't be defined using the > normal array literals :-)
I was wrong, this is not so bad looking:
struct List(T) {
// Node of std.range.SListRange is not static!
static struct Node {
T data;
Node* next;
this(T d, Node* p=null) {
data = d;
next = p;
}
}
Node* lh;
this(T[] arr) {
foreach_reverse (el; arr)
lh = new Node(el, lh);
}
}
void main() {
List!int items = [1, 2, 3];
}
Bye,
bearophile
