Hi there,
a silly question from me for the turn of the year... I apparently missing the forest through the trees.
The first part of the code works as expected:

[code]
    int[] arr8 = [1,2,3,4,5];

    int sum = 0;
    foreach(int summand; arr8)
    {
        sum += summand;
    }
    writeln("sum1: ", sum);

    writeln("sum2: ", reduce!((a,b) => a + b)(arr8));
[/code]

The second one does not:

[code]
    import std.bitmanip;

BitArray[] arr7 = [BitArray([0, 1, 0, 1, 0, 1]), BitArray([0, 1, 0, 0, 0, 0]), BitArray([0, 1, 0, 1, 0, 0]), BitArray([0, 1, 0, 1, 0, 0])];

    BitArray common = BitArray([1,1,1,1,1,1]);
    foreach(BitArray ba; arr7)
    {
        common &=  ba;
    }
    writeln("common2: ", common);

    //writeln("common1: ", reduce!((a,b) => a & b)(arr7));
[/code]

The problem is, that the last line with the reduce does not compile. Why?

Reply via email to