Support pattern as index in for-loops

Closes #3