Patterns, Functions and Algebra