implement indexed-pattern pattern-matching