Raw literal strings in Julia

坚强是说给别人听的谎言 提交于 2019-12-05 00:21:06

From Julia 0.6 we have raw"\a$variable"

Ok, I just found out that since one can easily create non-standard string literals in Julia, a pass-through one will do what I was asking for:

macro R_str(s)
    s
end

>>> R"$a\n$b"
"\$a\\n\$b"
>>> print(R"$a\n$b")
$a\n$b

I also discovered that PyPlot.jl defines a «LaTeXString type which can be constructed via L"...." without escaping backslashes or dollar signs», with the additional benefit of rendered equations in IJulia.

A last question remains: is not worth it to have a raw string literal in Julia base?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!