There has been a lot of work in genetic programing (GP) in this vein. Automatically defined functions are a big deal in GP and figuring out how many and what kinds of ADF's you should have (the "Architecture") has been the subject of a lot of research as well. More generally some people have looked at how to use GP to create libraries that it can then work with to make new more complex functions.
GP can often create perfect solutions like reversing a list or sorting lists. More often how ever it generates approximate solutions. It is really clever what all it can do however. John Koza (a really big name in GP) used genetic programing to find entirely new circuits that had never been created before and were effectively open problems in electrical engineering. To do this he had it design everything from the ground up but it had many recognizable circuits as sub parts. One could imagine that it might have made these things faster if it had already had those designed parts in its library.