def prepend_values
import bendvy-ecs-core@0.1.0.4/event_publication.bend as EventPublicationimport Base
34# Reverse-accumulate each record's values, then reverse once. Both traversals
35# decrease before the accumulator and preserve order within/across records.
36def prepend_values(~E:Data,values:List<&2,E>,reversed:List<&2,E>) -> List<&2,E>:
37 match values:
38 case []:reversed
39 case head <> rest:prepend_values(~E,rest,head <> reversed)