Julia
Resources¶
Documentation¶
Tutorials¶
- Compilation: Tutorials
Cheatsheets¶
Context¶
Environment¶
Editors¶
-
Documentation ยท The Julia Language
-
VS Code shows documentation when you hover over a function name. You can also use the Julia panel in the sidebar to search for documentation.
-
Julia REPL¶
ans stores the result.
To print objects:
To view dataframes, run:
Syntax¶
Functions¶
Broadcasting¶
Control flow¶
Symbols¶
Missing values¶
-
Missing Values ยท The Julia Language
Julia provides support for representing missing values in the statistical sense. This is for situations where no value is available for a variable in an observation, but a valid value theoretically exists. Missing values are represented via the
missingobject, which is the singleton instance of the typeMissing.missingis equivalent toNULLin SQL andNAin R, and behaves like them in most situations.
Pipes¶
-
Julia has native piping functionality in the |> operator, allowing f(g(x)) to be written as x |> g |> f. However, once you want to do mode advanced operations like using multi-argument functions, the core functionality is lacking. A pull-request was created to address this in 2017, but progress has halted. Instead, there is now a number of different packages that implement advanced piping, in slightly different flavours.
Metaprogramming¶
-
Macros are necessary because they execute when code is parsed, therefore, macros allow the programmer to generate and include fragments of customized code before the full program is run.
Types¶
-
5. Introduction to Types and Generic Programming โ Quantitative Economics with Julia
-
6.2. Exploring Type Trees โ Quantitative Economics with Julia
-
Diagram with all Julia types? - General Usage - Julia Programming Language
-
3.2. Common Data Types โ Quantitative Economics with Julia
Subtypes and supertypes¶
# Subtype operator `<:(T1, T2)`
# -> returns true iff all values of type T1 are also of type T2.
Number <: Any
subtypes(Any)
subtypes(Number)
subtypes(Real)
subtypes(Integer)
subtypes(Bool) # empty
supertypes(Bool)
?Vector{Float64} # Vector{T} is an alias for Array{T,1}
?Matrix{Float64} # Matrix{T} is an alias for Array{T,2}
Abstract and concrete types¶
TBD
Constructors¶
-
Constructors ยท The Julia Language
Constructors are functions that create new objects --- specifically, instances of Composite Types. In Julia, type objects also serve as constructor functions: they create new instances of themselves when applied to an argument tuple as a function.
Arrays¶
- Single- and multi-dimensional Arrays ยท The Julia Language
- 4. Arrays, Tuples, Ranges, and Other Fundamental Types โ Quantitative Economics with Julia
Tuples¶
Packages and modules¶
Modules¶
-
-
The recommended style is not to indent the body of the module, since that would typically lead to whole files being indented.
-
Also, it is common to use UpperCamelCase for module names (just like types), and use the plural form if applicable, especially if the module contains a similarly named identifier, to avoid name clashes.
-