Two studies examined how examples and their explanations affect learning to program recursive functions. The results are analyzed in the context of a production system model of analogical problem solving, cognitive skill acquisition, and practice. In Experiment 1, subjects received an example of a recursive function, were trained to criterion on one set of recursive functions, and were tested on transfer to a larger set of recursive functions. The structure of the example solution (how it was written) was explained to one group of subjects, whereas the process generated by the example (how it worked) was explained to another group. The explanation of structure was found to reduce training time when compared with the explanation of process. In Experiment 2, subjects were presented with examples that shared many parts of their solutions with training problems (high-similarity examples) or shared few parts with training problems (low-similarity examples). Examples reduced errors on the first opportunity for ...