-
Notifications
You must be signed in to change notification settings - Fork 131
feat: Add Array.scan{l,r,lM,rM} #1589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The |
|
WIP |
|
awaiting-review |
|
(as mentioned above this is failing ci currently because the |
This PR adds the Array equivalents of List.scan{l,r,L,R}. It was originally part of #1581.
Array.scanlandArray.scanrin terms of them. This is identical to how the standard library currently handlesArray.fold*.unsafein the implementations of the efficient versions. It defines an assumption (asArray.size_fits_usize) as well as anunsafeproof of this assumption (asArray.unsafe_size_fits_usize).These are currently public definitions. I could make them private, but they seem useful for writing other 'efficient' array functions.Array.scanlMis proven to be equivalent to its efficient implementation under the assumption thatArray.size_fits_usizeholds. The efficient version ofArray.scanrMadditionally uses this assumption when constructing the proofs for the bounds checks.Array.scanrMis equivalent to its efficient version underArray.size_fits_usize. It should be possible, but the structure of these two implementations differ more, so the proof is more difficult. WithArray.scanlMthe only difference between the implementations was the use ofUSizeorNatfor the index, whereas theArray.scanrMreference implementation builds the array, then reverses it and the efficient implementation iterates over the array in reverse.