fix(util/lazy_list): bug in filter operation
This commit is contained in:
parent
b7dcb8f833
commit
b482f27543
2 changed files with 9 additions and 1 deletions
|
@ -189,6 +189,13 @@ void tst5() {
|
|||
display(take(10, l));
|
||||
}
|
||||
|
||||
void tst6() {
|
||||
auto l = mk_gen();
|
||||
unsigned counter = 0;
|
||||
for_each(filter(take(10, l), [](unsigned v) { return v % 2 == 0; }), [&](unsigned) { counter++; });
|
||||
lean_assert(counter == 5);
|
||||
}
|
||||
|
||||
int main() {
|
||||
save_stack_info();
|
||||
tst1();
|
||||
|
@ -196,5 +203,6 @@ int main() {
|
|||
tst3();
|
||||
tst4();
|
||||
tst5();
|
||||
tst6();
|
||||
return has_violations() ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ lazy_list<T> filter(lazy_list<T> const & l, P && pred, char const * cname = "laz
|
|||
if (!p) {
|
||||
return p;
|
||||
} else if (pred(p->first)) {
|
||||
return p;
|
||||
return some(mk_pair(p->first, filter(p->second, pred, cname)));
|
||||
} else {
|
||||
check_system(cname);
|
||||
return filter(p->second, pred, cname).pull();
|
||||
|
|
Loading…
Reference in a new issue