iBet uBet web content aggregator. Adding the entire web to your favor.
iBet uBet web content aggregator. Adding the entire web to your favor.



Link to original content: http://julialang.org/learning/code-examples/
Code examples


Code examples

Check out the benchmark page to learn more about Julia's performance versus other languages

In this example, we will play around with the Mandelbrotset which can be programmed in Julia using the below code. You can press "Run" below to see the output and feel free to try your own examples in this empty REPL:

function mandelbrot(a)
    z = 0
    for i=1:50
        z = z^2 + a
    end
    return z
end

for y=1.0:-0.05:-1.0
    for x=-2.0:0.0315:0.5
        abs(mandelbrot(complex(x, y))) < 2 ? print("*") : print(" ")
    end
    println()
end

# Taken from: https://rosettacode.org/wiki/Mandelbrot_set#Julia