Update Julia syntax test

This commit is contained in:
David Peter 2021-07-13 09:07:29 +02:00
parent 3da4651569
commit 64763eafbe

View File

@ -1,10 +1,10 @@
x = 3 x = 3
y = 2x y = 2x
typeof(y) typeof(y)
f(x) = 2 + x f(x) = 2 + x
f f
@ -12,44 +12,44 @@
f(10) f(10)
function g(x, y) function g(x, y)
 z = x + y  z = x + y
 return z^2  return z^2
end end
g(1, 2) g(1, 2)
let s = 0 let s = 0
 for i in 1:10  for i in 1:10
 s += i # Equivalent to s = s + i  s += i # Equivalent to s = s + i
 end  end
 s  s
end end
typeof(1:10) typeof(1:10)
function mysum(n) function mysum(n)
 s = 0  s = 0
 for i in 1:n  for i in 1:n
 s += i  s += i
 end  end
 return s  return s
end end
mysum(100) mysum(100)
a = 3 a = 3
a < 5 a < 5
if a < 5 if a < 5
 "small"  "small"
else else
 "big"  "big"
end end
v = [1, 2, 3] v = [1, 2, 3]
typeof(v) typeof(v)
@ -57,15 +57,15 @@
v[2] = 10 v[2] = 10
v2 = [i^2 for i in 1:10] v2 = [i^2 for i in 1:10]
M = [1 2 M = [1 2
 3 4]  3 4]
typeof(M) typeof(M)
zeros(5, 5) zeros(5, 5)
zeros(Int, 4, 5) zeros(Int, 4, 5)
[i + j for i in 1:5, j in 1:6] [i + j for i in 1:5, j in 1:6]