As a side note, this code will throw an error on Julia 1.3 or earlier if v does not contain any positive numbers. See this thread:
v