By following the examples in the Manual of Product of List block, I modified the library function all of predicates block. I ran into a subtle situation that I don't understand:
The expected behavior is: d should return false when c at 5, but instead it stopped at 6. I could not figure out the reason.
Here my all of predicates used a helper function which uses call with continuation to stop, I am testing this in order to make use of this feature in certain situations that I needed to do early termination during fold/reduce/scan operations on the list.
Never mind, I figured out the problem, in certain cases, this may not be critical, but if you are relying on certain state to be precisely the moment something tested positive or negative, it's important to pay attention to this subtle detail.
You can compare this newer version with the version contained inside the previous script pic.
because in the previous instruction you've already established that the first item is true. If it were false, running the continuation would never return here; that's the whole point of continuations!
But the script you actually posted is weird and I don't understand it. I think that you probably mean
I take it back, this optimization does not work unless I put it into the else block, my 1st posted version did not use the else block (same as the example in the product list block in the manual).
No, I think this is similar to one problem I discovered during the generalized sorting problem. a is defined to be ring, and that green circle a is just the identity function, if placing a directly in there, it won't work, for some reasons... Do you know why?
I just checked the example in the manual, it does not work either, even worse, I don't think it ever stopped... @bh, could you please explain to me why? It maybe a real bug?
Oh. I looked again and found a problem. In your helper function you declare CONT to be of type Any (Unevaluated). Instead it should be of type Reporter.
Brief explanation: Unevaluated input types effectively wrap an invisible ring around whatever expression you give as the actual input. So when ALL OF calls ALL OF HELPER with input , the input value is instead of the actual continuation. So calling it doesn't work.
If that's not enough of an explanation, go reread Section VI.E of the Reference Manual and then come back with a specific question if that isn't clear.
So if you fix that, it should all work without that redundant REPORT.