You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
InputRange.take(n).filter.chain logically transforms it into InputRange.filter.take(n-1).chain and thus takes the wrong number of elements
Example:
----
import std.stdio;
import std.algorithm;
import std.range;
auto inputRangeFactory(){
int i = 0;
int gen(){
return i++;
}
return generate!gen();
}
void main(){
// [10, 11, 12, 13, 14, 15, 16, 17, 18, 100]inputRangeFactory.take(10).filter!"a>8".chain(only(100)).writeln;// Unless filter would discard all taken elements// [100]inputRangeFactory.take(10).filter!"a>9".chain(only(100)).writeln;// Adding "array" somewhere in the middle fixes it// [9,100]inputRangeFactory.take(10).array.filter!"a>8".chain(only(100)).writeln;inputRangeFactory.take(10).filter!"a>8".array.chain(only(100)).writeln;
}
------
$ dmd --version
DMD64 D Compiler v2.109.1
Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved written by Walter Bright
The text was updated successfully, but these errors were encountered:
qigezx+dc40d6nao940k reported this on 2024-09-20T13:14:28Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=24775
Description
The text was updated successfully, but these errors were encountered: