Last active
August 31, 2020 01:09
-
-
Save liuyxpp/784d9935d5e3eeeb2212eeee4535dbbb to your computer and use it in GitHub Desktop.
List/Display all math constants and operators defined as Unicode symbols in Julia Base
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credit of `math_symbols`: Tom Kwong (@tomkwong) | |
# Credit of `unicodesymbol2string`, `display_math_symbols`: Yi-Xin Liu (@lyxfudan) | |
# 2020.08.31 | |
using REPL: symbol_latex | |
function math_symbols() | |
allnames = names(Base) | |
name_length = [allnames length.(String.(allnames))] | |
syms = filter(!(isascii ∘ String), name_length[name_length[:,2].==1, 1]) | |
return syms | |
end | |
function unicodesymbol2string(us) | |
us = string(us) | |
return isascii(us) ? us : isempty(symbol_latex(us)) ? us : symbol_latex(us)[2:end] | |
end | |
""" | |
Example: π can be typed by \pi<tab> in the Julia REPL or VS Code. | |
""" | |
function display_math_symbols() | |
syms = math_symbols() | |
cmds = unicodesymbol2string.(syms) | |
for i in eachindex(syms) | |
println(syms[i], "\t", cmds[i]) | |
end | |
return nothing | |
end | |
display_math_symbols() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment