Tutorial by Examples

In Julia, the @show macro is often useful for debugging purposes. It displays both the expression to be evaluated and its result, finally returning the value of the result: julia> @show 1 + 1 1 + 1 = 2 2 It is straightforward to create our own version of @show: julia> macro myshow(exp...
We're all used to the while syntax, that executes its body while the condition is evaluated to true. What if we want to implement an until loop, that executes a loop until the condition is evaluated to true? In Julia, we can do this by creating a @until macro, that stops to execute its body when th...
There are three ways to quote something using a Julia function: julia> QuoteNode(:x) :(:x) julia> Meta.quot(:x) :(:x) julia> Expr(:quote, :x) :(:x) What does "quoting" mean, and what is it good for? Quoting allows us to protect expressions from being interpreted as sp...
π's Metaprogramming bits & bobs Goals: Teach through minimal targeted functional/useful/non-abstract examples (e.g. @swap or @assert) that introduce concepts in suitable contexts Prefer to let the code illustrate/demonstrate the concepts rather than paragraphs of explanation Avoi...
Introduction Julia uses the following syntax for dictionaries: Dict({k₁ => v₁, k₂ => v₂, …, kₙ₋₁ => vₙ₋₁, kₙ => vₙ) While Python and JSON looks like this: {k₁: v₁, k₂: v₂, …, kₙ₋₁: vₙ₋₁, kₙ: vₙ} For illustrative purposes we could also use this syntax in Julia and add new seman...

Page 1 of 1