Pattern match function for Lisp