<jupyter_start><jupyter_text>"Julia"> "Basics of the julia language"- author: <NAME>- toc: true- branch: master- badges: true- comments: true- categories: [julia ]- hide: true- search_exclude: true<jupyter_code>answer = 43
x = 2
1 < x < 3
M = [1 0; 0 1]
typeof(size(M))<jupyter_output><empty_output><jupyter_text>Basics  Assignement<jupyter_code>answer = 42
x, y, z = 1, [1:10; ], "A string" # just like in python !
x, y = y, x # swap x and y<jupyter_output><empty_output><jupyter_text>Declaring Constants<jupyter_code>const DATE_OF_BIRTH = 2012<jupyter_output><empty_output><jupyter_text>Commenting<jupyter_code>1 + 1 # Hello, this is a comment!<jupyter_output><empty_output><jupyter_text>Delimited comment<jupyter_code>1 + #= This comment is inside code! =# 1<jupyter_output><empty_output><jupyter_text>Chaining<jupyter_code>x = y = z = 1  # right-to-left
0 < x < 3  #works
z = 10
b = 2
x < y < z < b # works too!<jupyter_output><empty_output><jupyter_text>Function definition<jupyter_code>function add_one(i)
    return i + 1 # Just a bit different to python.
end

add_one(2)<jupyter_output><empty_output><jupyter_text>Insert LaTeX symbolsNow this is a cool feature...in a code cell type for example \alpha + Tab<jupyter_code>β = 1<jupyter_output><empty_output><jupyter_text>Operators  Basic Arithmetic works as expected<jupyter_code>println(1 + 1)
println(1 - 3)
println(3 * 3)
println(4 / 2)<jupyter_output>2
-2
9
2.0<jupyter_text>Exponentiation<jupyter_code>2^2 # note the difference to python 2 ** 2<jupyter_output><empty_output><jupyter_text>Remainder<jupyter_code>4 % 3<jupyter_output><empty_output><jupyter_text>Negation<jupyter_code>!true # note the difference to numpys ~<jupyter_output><empty_output><jupyter_text>Equality<jupyter_code>true == true<jupyter_output><empty_output><jupyter_text>Inequality<jupyter_code>true != true<jupyter_output><empty_output><jupyter_text>Elementwise operation<jupyter_code>[1 2; 3 3] .* [9 9;9 9] # elementwise
[1 2; 3 3] * [9 9;9 9] #matrix materix product<jupyter_output><empty_output><jupyter_text>Check for nan<jupyter_code>isnan(9)<jupyter_output><empty_output><jupyter_text>Ternary operator The syntax iscond ? do_true : else<jupyter_code>1 != 1 ? println(3) : println(999)<jupyter_output>999<jupyter_text>And/or<jupyter_code>true && true
false || true<jupyter_output><empty_output><jupyter_text>Sources - [ ] https://juliadocs.github.io/Julia-Cheat-Sheet/- [ ] https://github.com/JuliaLang/julia- [ ] https://arxiv.org/pdf/2003.10146.pdf- [ ] https://github.com/h-Klok/StatsWithJuliaBook- [ ] juliahub- [ ] juliaacademy- [ ] https://www.sas.upenn.edu/~jesusfv/Chapter_HPC_8_Julia.pdf- [ ] https://www.packtpub.com/product/hands-on-design-patterns-and-best-practices-with-julia/9781838648817- [ ] https://www.elsevier.com/books/introduction-to-quantitative-macroeconomics-using-julia/caraiani/978-0-12-812219-8- [ ] https://colab.research.google.com/github/ageron/julia_notebooks/blob/master/Julia_for_Pythonistas.ipynbscrollTo=EEzvvzCl1i0F- [ ] https://cheatsheets.quantecon.org/<jupyter_code><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1403964900877478, 'fraction_numerical': 0.03737406564835879, 'mean_word_length': 6.812182741116751, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 77, 'https://': 9, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '19', 'dir': 'jupyter-structured-clean-dedup', 'id': '667571', 'license': 'Apache-2.0', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1244, 'n_words': 192, 'path': '_notebooks/2020-10-20-julia.ipynb', 'repo_name': 'ChristopherTh/statistics-blog', 'size': '3091'}