In-place mapping through a statically linked function #
The source operation takes a borrowed array in its first two parameter slots.
It keeps an index, uses the ordinary forIn load and cursor updates,
and calls the fixed source function fn before storing each returned word.
The remaining slots are private locals, exactly as in the named DSL declaration
with for i, x in xs { let y ← call helper(x); xs[i] := y; }.
The mathematical transformation below describes a verified callee; it is not an executable Lean callback or a second interpretation of the program.
One actual helper call, indexed store and explicit index increment. The iteration mechanism supplies the element in local 5.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Initialize the public source index and traverse the borrowed array.
Equations
- Ram.Source.Array.Map.code fn = (Ram.Stmt.assign 2 (Ram.Expr.const 0)).seq (Ram.Stmt.forIn 3 4 5 (Ram.Expr.var 0) (Ram.Expr.var 1) (Ram.Source.Array.Map.body fn))
Instances For
The ordinary source function underlying the reusable map operation. Its helper index is resolved statically, not passed in a runtime word.
Equations
- Ram.Source.Array.Map.function fn = { params := 2, locals := 7, body := Ram.Source.Array.Map.code fn, results := [] }
Instances For
The shared effects and local assignments of the body after loading an element.
Equations
Instances For
A callee contract at the actual loaded word suffices for the body. The callee preserves shared state; the subsequent real store changes the array.
Completed bodies preserve the private remaining count independently of the helper's behavior: the actual call restores caller locals before binding its result.