each ? can be either a . or a # check pattern to match the int list
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | i | |||
| integer, | intent(in) | :: | n |
recursive subroutine test (i, n) !! each ? can be either a . or a # !! check pattern to match the int list integer, intent(in) :: i, n integer :: ix integer,dimension(*),parameter :: icoeffs = [POINT,NUMBER] !! set of coefficients ['.', '#'] ! what we are not doing here is accounting for permutations ! that we know do not match, because the begin with a sequence ! that doesn't match. those need to be skipped... if (i > n) then ! so we have an array of 0s and 1s -> replace the 2s in the ipattern with these ! ipattern: 2220111 -> ???.### ! a: 011 -> .## ! result: 0110111 -> .##.### !write(*,'(a,1x,i5,1x, *(I1))') 'test:', iline, ipattern_tmp ipattern_tmp = unpack(a, mask=ipattern==QUESTION, field=ipattern) if (match(ipattern_tmp, ints)) n_valid = n_valid + 1 else do ix = 1, 2 a(i) = icoeffs(ix) call test(i+1, n) end do end if end subroutine test