User/Console Input (read, readline, input)

,

Unfortunately, it is, at the moment you depart from the implicit assumption that the REPL is a command-line process with direct access to a terminal.

Your “personalized hello world” example is indeed used as an introduction in many languages. But in Julia you can also do many other basic things that are basic, and display the comparative advantages of the language.

Eg simulate \pi:

function simulated_unit_circle_area(N)
    count_inside = 0
    for _ in 1:N
        x = rand() * 2 - 1
        y = rand() * 2 - 1
        if abs2(x) + abs2(y) ≤ 1
            count_inside += 1
        end
    end
    count_inside / N * 4
end

my_π = simulated_unit_circle_area(1000000)
1 Like