On Wednesday, 9 September 2015 at 07:19:06 UTC, Bahman Movaqar wrote:
The only way to make it work is `.array.idup` the output of `filter`. For example:

    auto result = reduce!(
      (acc, num) => acc.filter!(
        fb => (fb.x < num && fb.y < num) && (fb.x * fb.y > num)
      ).array.idup
    )(foobars, nums);

Honestly, I cannot comprehend anything out of this; why I had to realise the lazy value and `idup` it for it to become usable by `reduce`?
Does this mean that I am simply missing something obvious?

Reduce takes the seed, calls your function, and your function returns a new seed.

What is going wrong is that the types aren't the same. That is, the type of the seed you supplied - `typeof(foobars)` - isn't the type that your function returns - `typeof(acc.filter!...)`.

`array()` fixes that, no idea why you need `idup()` though.

OT: I wonder, is reduce able to call a different templated version of reduce?

Reply via email to