O'Reilly logo

Learning Jupyter by Dan Toomey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Julia control flow

Julia has a complete set of control flows. As an example, we could have a small function that determines the larger of two numbers:

function larger(x, y) 
    if (x>y) 
        return x
    end
    return y
end
println(larger(7,8))

There are several features that you must note:

  • The end statement for the if statement
  • end the closing of the function
  • Indentation of the statements within the function
  • Indentation of the handling of a true condition within an if statement

If we run this in Jupyter, we see the output shown in the following screenshot:

Julia control flow

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required