equals is not enough lazy
xgbuils opened this issue · 4 comments
xgbuils commented
It is obvious that is imposible to avoid this infinite loop
const list1 = drop(1, range(0, Infinity))
const list2 = drop(1, range(0, Infinity))
equals(list1, list2) // infinite loop
But what about that?
const naturals = range(0, Infinity)
equals(naturals, assoc(2, 42, naturals)) // It should return false
I think that it could return false using finite time.
Cheers!
xgbuils commented
includes has the same caveat.
benji6 commented
Very good point on equals
- I will investigate! Do you have an example with includes
? There's a test case with an infinite iterable here which passes https://github.com/benji6/imlazy/blob/master/test/includes.js#L8
xgbuils commented
Of course, I mean includes
uses equals
. Then it seems that
const naturals = range(0, Infinity)
includes(naturals, [assoc(2, 42, naturals)])
could have the same problem.
benji6 commented
ah yes! good point :)