The #julialang defines a number of standard constants and operators as Unicode symbols. Want to find out how to write mathy code? Continue reading this thread below.

đŸ§”đŸ‘‡
Math constants and common functions:
π: pi constant
ℯ: Euler’s number
√: square root function
∛: cube root function
Ă·: integer division operator
⊻: XOR operator

2/11
Membership operators
∈: is in
∉: is not in
∋: contains
∌: does not contain
3/11
Comparison operators
≈: is approximately equals to
≉: is not approximately equals to
≠: does not equal
≡: is identical to
≱: is not identical to
≀: less than or equal to
≄: greater than or equal to
4/11
Set operators
∩: intersection of
âˆȘ: union of
⊆: is subset of
⊇: is superset of
⊈: is not subset of
⊉: is not superset of
⊊: is subset but not equal to
⊋: is superset but not equal to
5/11
Using Unicode can make the code look more concise. However, it takes more effort to enter Unicode symbols. The julia langugage manual has a great reference table for Unicode inputs. See https://docs.julialang.org/en/v1/manual/unicode-input/
6/11
Is it a good idea to use Unicode symbols in code? It think it depends on context. If the programmers are good with math then it is a godsend to be able to read/write code with Unicode. Remember: we need to consider not just the author but also future maintainers of the code.
7/11
Note that some fonts such as Fira Code or Cascadia support ligatures. So, even normal code can sometimes be displayed in Unicode anyways. For examples, ≠ and ≡ are displayed as Unicode for !== and === respectively.
8/11
The help mode can also display doc strings for these standard Unicode-symbol functions.
9/11
So how did I find out which Unicode symbols were defined in Base? It’s actually pretty straight forward.
10/11
I can’t believe you’ve come this far😄
Thank you for reading. I hope you learn something new today.
11/11
You can follow @tomkwong.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: