Book Image

Getting Started with Julia

By : Ivo Balbaert
Book Image

Getting Started with Julia

By: Ivo Balbaert

Overview of this book

Table of Contents (19 chapters)
Getting Started with Julia
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The Rationale for Julia
Index

Built-in macros


Needless to say the Julia team has put macros to good use. To get the help information about a macro, enter a ? in the REPL, and type @macroname after the help> prompt, or type help("@macroname"). Apart from the built-in macros we encountered in the examples in the previous chapters, here are some other very useful ones (refer to the code in Chapter 7\built_in_macros.jl).

Testing

The @assert macro actually exists in the standard library. The standard version also allows you to give your own error message, which is printed after ERROR: assertion failed.

The Base.Test library contains some useful macros to compare the numbers:

using Base.Test
@test 1 == 3

This returns ERROR: test failed: 1 == 3.

@test_approx_eq tests whether the two numbers are approximately equal. @test_approx_eq 1 1.1 returns ERROR: assertion failed: |1 - 1.1| <= 2.220446049250313e-12 because they are not equal within the machine tolerance. However, you can give the interval as the last argument within which...