Re: struct vs built-in type

2014-12-17 Thread Jack Applegame via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 08:09:44 UTC, Daniel Kozák via 
Digitalmars-d-learn wrote:

This should work only with ref by spec

I totally agree.


Re: Russian translation of the range term?

2014-11-12 Thread Jack Applegame via Digitalmars-d-learn

интервал, область



std.array.array and immutable elements

2014-11-07 Thread Jack Applegame via Digitalmars-d-learn

DMD64 D Compiler v2.066.1
Why second call doesn't compile?

import std.array;
import std.algorithm;

class Foo {
bool flag;
}
void main() {
  immutable(Foo)[] foos;
  foreach(i; 0..5) foos ~= new Foo;

  // compiles, typeof(bar1) == immutable(Foo)[]
  auto bar1 = array(foos.filter!(i = i.flag));

  // fails, expected typeof(bar2) == immutable(Foo)[]
  auto bar2 = array(foos.map!(i = i));
}

Error: cannot implicitly convert expression (arg) of type 
immutable(Foo) to test.Foo
Error: template instance 
std.conv.emplaceRef!(immutable(Foo)).emplaceRef!(immutable(Foo)) 
error instantiating
instantiated from here: array!(MapResult!(__lambda2, 
immutable(Foo)[]))


transversal sum

2014-11-06 Thread Jack Applegame via Digitalmars-d-learn

I have rectangular forward range of forward ranges (not arrays):
[
  [a11, a12, ... a1N],
  [a21, a22, ... a2N],
  ...
  [aM1, aM2, ... aMN]
]

I need lazy forward range:
[
 a11 + a21 + ... aM1,
 a12 + a22 + ... aM2,
 ...
 a1N + a2N + ... aMN
]
Range of sum elements of every columns;

M, N - runtime values;

Is there a way to do this using only Phobos algorithms and range 
functions?


Re: transversal sum

2014-11-06 Thread Jack Applegame via Digitalmars-d-learn

void popFront() { foreach (ref r; rr) r.popFront(); }

I think it should be
void popFront() { foreach (ref r; rr.save) r.popFront(); }


but I think OP wanted a ready-made phobos solution, w/o all the
range boilerplate...

exactly.


Why std.variant.Varian.get is mutable

2014-10-21 Thread Jack Applegame via Digitalmars-d-learn

This doesn't compiles
http://dpaste.dzfl.pl/bbcc31fbe016


Very strange compilation error

2014-10-15 Thread Jack Applegame via Digitalmars-d-learn

I don't understand why this code doesn't compile:

http://dpaste.dzfl.pl/dfd8df7f80ad


<    1   2