added a sequence factory function
moved to a functional metaprogramming interface for generating pattern functions