In nature, self-assembling and disassembling complexes of proteins and nucleic acids bound to a variety of ligands perform intricate and diverse dynamic functions. In contrast, attempts to rationally encode structure and function into synthetic amino acid and nucleic acid sequences have largely focused on engineering molecules that self-assemble into prescribed target structures, rather than on engineering transient system dynamics. To design systems that perform dynamic functions without human intervention, it is necessary to encode within the biopolymer sequences the reaction pathways by which self-assembly occurs. Nucleic acids show promise as a design medium for engineering dynamic functions, including catalytic hybridization, triggered self-assembly and molecular computation. Here, we program diverse molecular self-assembly and disassembly pathways using a `reaction graph' abstraction to specify complementarity relationships between modular domains in a versatile DNA hairpin motif. Molecular programs are executed for a variety of dynamic functions: catalytic formation of branched junctions, autocatalytic duplex formation by a cross-catalytic circuit, nucleated dendritic growth of a binary molecular `tree', and autonomous locomotion of a bipedal walker.