generic apply pattern for from end