After revising this thread, two observations if you will:
(i) The OP (@Andrea_Tersigni) seems to have accidentally deleted the original question?
(ii) The Julia’s adage that loops are fast, was not tested in examples above. For the record, the simple loop below seems to run faster for large N (say N > 10^6):
function g6(r)
x = 0 ::Int
for i in r
if i > 1.96
x += 1
end
end
return x
end