Basic Julia types for data visualization
xxxxxxxxxx
3
1
md"""
2
# Basic Julia types for data visualization
3
"""
Functions
xxxxxxxxxx
3
1
md"""
2
## Functions
3
"""
addition (generic function with 1 method)
xxxxxxxxxx
3
1
function addition(x, y)
2
x + y
3
end
subtraction (generic function with 1 method)
xxxxxxxxxx
1
1
subtraction(x, y) = x - y
Higher-order and anonymous functions
xxxxxxxxxx
3
1
md"""
2
### Higher-order and anonymous functions
3
"""
2
xxxxxxxxxx
1
1
sum(abs, [-1, 1])
2
xxxxxxxxxx
1
1
sum(x -> abs(x), [-1, 1])
2
xxxxxxxxxx
3
1
sum([-1, 1]) do x
2
abs(x)
3
end
Julia types
xxxxxxxxxx
3
1
md"""
2
## Julia types
3
"""
String
xxxxxxxxxx
1
1
typeof("Hello World")
Int64
xxxxxxxxxx
1
1
typeof(2)
xxxxxxxxxx
1
1
using PlutoUI
1:5
xxxxxxxxxx
1
1
numbers = 1:5
UnitRange{Int64}
start: Int64 1
stop: Int64 5
xxxxxxxxxx
1
1
Dump(numbers)
1
xxxxxxxxxx
1
1
numbers.start
5
xxxxxxxxxx
1
1
numbers.stop
Multiple dispatch
xxxxxxxxxx
3
1
md"""
2
### Multiple dispatch
3
"""
concatenate (generic function with 1 method)
xxxxxxxxxx
1
1
concatenate(a::String, b::String) = a * b
"HelloWorld"
xxxxxxxxxx
1
1
concatenate("Hello", "World")
concatenate (generic function with 2 methods)
xxxxxxxxxx
1
1
concatenate(a::Int, b::Int) = parse(Int, string(a) * string(b))
12
xxxxxxxxxx
1
1
concatenate(1, 2)