println("Hello, World")
#> Hello, World1 Introduction
1.1 Hello World
println() print to newline.
1.2 Assign Variable
Dynamic typing
my_int = 10
#> 10
typeof(my_int)
#> Int64my_pi = 3.1416
#> 3.1416
typeof(my_pi)
#> Float64😸 = "smily cat"
#> "smily cat"
typeof(😸)
#> StringSting interpolation with $
"This is $😸"
#> "This is smily cat"😀 = 1
😞 = -1
🤐 = 0🤐 == 😀 + 😞
#> true1.3 Comment
# This is comment#=
This
is
Multiline Comment
=#1.4 Basic Math
1 + 1
#> 21 - 1
#> 02 * 3
#> 63 / 2
#> 1.5like R
10 ^ 2
#> 100like Python
5 % 2
#> 11.5 Operator
Boolean Operators
!true
#> false
false && true
#> false
false || true
#> trueLogical Operator ignore type
1 == 1.0
#> true1.6 Vectorized “dot” operators
[1,2,3] ^ 3
# This would Error[1,2,3] .^ 3
#> 3-element Vector{Int64}:
#> 1
#> 8
#> 27a .^ b is parsed as the “dot” call (^).(a,b), which performs a broadcast operation:
- combine arrays and scalars,
- arrays of the same size (performing the operation elementwise)
- even arrays of different shapes (e.g. combining row and column vectors to produce a matrix).
1.7 Exercise
convert() function
days = 365days_float = convert(Float64, days) # Convert to Float64
#> 365.0days == days_float
#> true@assert days == 365
@assert days_float == 365.0convert(Int64, "1") # Errorparse(Int64, "1")
#> 1