on master help sign in
add julia test file
78c9a5dhenil
tests/syntax-tests/highlighted/Julia/test.jlnew file+73
@@ -0,0 +1,73 @@
1+# The `test.jl` file has been adapted from [https://github.com/mitmath/18S191/blob/master/lecture_notebooks/Basic%20Julia%20syntax.jl] and is subject to no license.
2+
3+x = 3
4+
5+y = 2x
6+
7+typeof(y)
8+
9+f(x) = 2 + x
10+
11+
12+f
13+
14+f(10)
15+
16+
17+function g(x, y)
18+ z = x + y
19+ return z^2
20+end
21+
22+g(1, 2)
23+
24+let s = 0
25+ for i in 1:10
26+ s += i # Equivalent to s = s + i
27+ end
28+ s
29+end
30+
31+
32+typeof(1:10)
33+
34+function mysum(n)
35+ s = 0
36+ for i in 1:n
37+ s += i
38+ end
39+ return s
40+end
41+
42+mysum(100)
43+
44+a = 3
45+
46+a < 5
47+
48+if a < 5
49+ "small"
50+else
51+ "big"
52+end
53+
54+v = [1, 2, 3]
55+
56+typeof(v)
57+
58+v[2]
59+
60+v[2] = 10
61+
62+v2 = [i^2 for i in 1:10]
63+
64+M = [1 2
65+ 3 4]
66+
67+typeof(M)
68+
69+zeros(5, 5)
70+
71+zeros(Int, 4, 5)
72+
73+[i + j for i in 1:5, j in 1:6]
tests/syntax-tests/source/Julia/test.jlnew file+73
@@ -0,0 +1,73 @@
1+# The `test.jl` file has been adapted from [https://github.com/mitmath/18S191/blob/master/lecture_notebooks/Basic%20Julia%20syntax.jl] and is subject to no license.
2+
3+x = 3
4+
5+y = 2x
6+
7+typeof(y)
8+
9+f(x) = 2 + x
10+
11+
12+f
13+
14+f(10)
15+
16+
17+function g(x, y)
18+ z = x + y
19+ return z^2
20+end
21+
22+g(1, 2)
23+
24+let s = 0
25+ for i in 1:10
26+ s += i # Equivalent to s = s + i
27+ end
28+ s
29+end
30+
31+
32+typeof(1:10)
33+
34+function mysum(n)
35+ s = 0
36+ for i in 1:n
37+ s += i
38+ end
39+ return s
40+end
41+
42+mysum(100)
43+
44+a = 3
45+
46+a < 5
47+
48+if a < 5
49+ "small"
50+else
51+ "big"
52+end
53+
54+v = [1, 2, 3]
55+
56+typeof(v)
57+
58+v[2]
59+
60+v[2] = 10
61+
62+v2 = [i^2 for i in 1:10]
63+
64+M = [1 2
65+ 3 4]
66+
67+typeof(M)
68+
69+zeros(5, 5)
70+
71+zeros(Int, 4, 5)
72+
73+[i + j for i in 1:5, j in 1:6]