Folding over Neural Networks