Recurrent and folding networks