1 + 2.0
3.0
typeof(3.3)
Float64
println("Hello World")
println("1 + 2 is: $(1 + 2)")
Hello World 1 + 2 is: 3
'a'
'\u2603'
'☃'
int('☃')
"2603"
['a' 'b' 'c']
1x3 Array{Char,2}: 'a' 'b' 'c'
['a' 'b' 'c';
'd' 'e' 'f';]
2x3 Array{Char,2}: 'a' 'b' 'c' 'd' 'e' 'f'
[1, 2, 3]
3-element Array{Int64,1}: 1 2 3
Dict(:erik => "python",
:justin => "ruby",
:colin => "scala",
)
Dict{Symbol,ASCIIString} with 3 entries: :erik => "python" :colin => "scala" :justin => "ruby"
a = 7
7
erik = :erik
:erik
erik::Symbol
:erik
erik::Array
type: typeassert: expected Array{T,N}, got Symbol while loading In[38], in expression starting on line 1
a = 3
if a > 4
println("a is too big")
else
println("a is $a")
end
a is 3
x = 1 == 2 ? "yeah!" : "nope..."
"nope..."
for x = 1:3:10
println(x)
end
1 4 7 10
o_count = 0
for x = "one two three"
if x == 'o'
o_count += 1
end
end
o_count
2
[x^2 for x = 1:5]
5-element Array{Int64,1}: 1 4 9 16 25
["$x $y" for x = 1:3, y='a':'c']
3x3 Array{Union(UTF8String,ASCIIString),2}: "1 a" "1 b" "1 c" "2 a" "2 b" "2 c" "3 a" "3 b" "3 c"
function minimum(l)
min = l[1]
for x = l[2:end]
min = min < x ? min : x
end
min
end
minimum([2, -3, 6, -4, 3])
-4
f(x) = 2x
f(3)
6
((x, y) -> x + y)(2, 3)
5
map(c -> c + 2, "Hello")
"Jgnnq"
filter(x -> x % 3 == 0, 1:10)
3-element Array{Int64,1}: 3 6 9