Macroify some sequence functions

Deleting evil code duplication.