Julia: Difference between revisions
No edit summary |
No edit summary |
||
Line 24: | Line 24: | ||
"Variable x is $x, y is $y, and x+y is $(x+y)" | "Variable x is $x, y is $y, and x+y is $(x+y)" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Higher order functions=== | |||
Julia supports high-order functions.<br> | |||
<syntaxhighlight lang="julia"> | |||
ts = ((a, b) -> (c, d) -> a + b + c + d)(1,2); | |||
</syntaxhighlight> | |||
The call with arguments (1,2) returns a function.<br> | |||
Then <code>ts</code> is equivalent to | |||
<syntaxhighlight lang="julia"> | |||
ts = (c, d) -> 1 + 2 + c + d; | |||
</syntaxhighlight> | |||
You can also use the full <code>function(a,b)</code> syntax. | |||
===Animation Loop=== | ===Animation Loop=== |
Revision as of 18:48, 9 September 2019
Basic Usage
Package Management
Guide Initializing a new project
cd project_folder
julia
] activate ./
# Add your packages
Loading an existing project
cd project_folder
julia
using Pkg;
Pkg.activate("./");
Pkg.instantiate();
String Interpolation
"Variable x is $x, y is $y, and x+y is $(x+y)"
Higher order functions
Julia supports high-order functions.
ts = ((a, b) -> (c, d) -> a + b + c + d)(1,2);
The call with arguments (1,2) returns a function.
Then ts
is equivalent to
ts = (c, d) -> 1 + 2 + c + d;
You can also use the full function(a,b)
syntax.
Animation Loop
You can use Timer(callback, delay, interval)
. This is similar to SetInterval in JavaScript.
animate = Timer(function(t)
println("Animating")
end, 0; interval=1/60)
Useful Packages
MeshCat.jl
Link
A wrapper for graphics visualizations around three.js. This opens in a web browser but can be used for making helium apps.