def prepend_values

bendvy-ecs-core@0.1.0.4 · event_publication.bend:34

import bendvy-ecs-core@0.1.0.4/event_publication.bend as EventPublication
import 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)

Uses (1)

Used by (2)