Carpet

Carpet

2M Downloads

`all` function returns true for empty lists

Xendergo opened this issue ยท 2 comments

commented

I'm not sure whether this is intended or not, but I figured I might as well report it anyways

If you run all(l(), false) you can see that it returns true, which seems kinda unintuitive to me

commented

Could you elaborate "all"? Nvm I understood "all functions"

In the case of all, it's because it only changes to false when it finds a result where the predicate returns false. Therefore, since there is nothing to return false,... well... it returns true. May be a good idea to change, let's wait for more opinions.

commented

that's exactly what the logic is. If you want to assert if all elements satisfy the condtion and at least one satisfies it as well, then lst && all(lst, cond) should do.