Writing Greek Characters and Subscripts in Julia Variable Names
Overview
In Julia, Unicode (UTF-8) is allowed for variable names. Therefore, you can use not only Greek letters but also superscripts, subscripts, and even Korean or emojis. There’s no particular need to use them, but odd codes like the following work fine.
julia> α₁ = 2
2
julia> α₂ = 1
1
julia> println(α₁ \ast\ α₂)
2
julia> 사인(t) = sin(t)
사인 (generic function with 1 method)
julia> 😂 = 1:20
1:20
julia> 사인.(😂)
20-element Array{Float64,1}:
0.8414709848078965
0.9092974268256817
⋮
0.14987720966295234
0.9129452507276277
Greek Letters
You can use all the Greek letters used in tex like the example above.
Superscripts, Subscripts
Superscripts and subscripts can be used by typing numbers after \_
, \^
. They’re too small to use frequently, but Greek letters, English, or parentheses can also be used.
Emoji
Emojis can be entered like in other editors by pressing window + .
(cmd + comma).