A model for learning and imprinting with finite and infinite memory range