Hi I am doing the pi exercise in JuliaBox and would like to know how I could use the ternary operator ( a ? b : c ) correctly. Any suggestions?
function calculate_pi(N,r)
Acircle = 0
Asquare = 0
for x in 1:N
x,y = rand([-1:1]), rand([-1:1])
dist = sqrt(x^2 + y^2)
dist < r ? Acircle++ : Asquare++
end
return 4*(Acircle/Asquare)
end
N = 1000
r = 1
calculate_pi(N, r)
ERROR
syntax: space not allowed after “:” used for quoting