Julia编程语言的新版本之所以受到整个人工智能界的关注,最主要的原因正是其将 C 语言的速度、Ruby 的灵活、Python 的通用性前所未有地结合在一起,支持并行处理,易于学习和使用,尤其适合科学和工程计算。
官方文档链接:
Julia Documentation · The Julia Language
软件下载链接:
▋〓〓特色〓〓▋可定义Unicode字符变量
▋〓〓特色〓〓▋str[k]与str[k:k]含义不同
特色内容详见下文。
字符
最简单的示例
julia> achar = 'A'
'A': ASCII/Unicode U+0041 (category Lu: Letter, uppercase)
julia> typeof(achar)
Char
字符变量转变为整数类型
julia> Int(achar)
65
julia> typeof(Int(achar))
Int64
整数类型转变为字符串
julia> Char(119)
'w': ASCII/Unicode U+0077 (category Ll: Letter, lowercase)
Unicode字符变量▋〓〓特色〓〓▋可定义Unicode字符变量
采用\u表示
julia> '\u120'
'Ġ': Unicode U+0120 (category Lu: Letter, uppercase)
字符计算与比较
julia> '\u120'+1
'ġ': Unicode U+0121 (category Ll: Letter, lowercase)
julia> '\u120'<'\u121'
true
字符串
简单示例(说明:类似C语言)
julia> str = "ABC"
"ABC"
字符索引(说明:类似MATLAB语言)
julia> str[begin]
'A': ASCII/Unicode U+0041 (category Lu: Letter, uppercase)
julia> str[0]
ERROR: BoundsError: attempt to access 3-codeunit String at index [0]
Stacktrace:
[1] checkbounds
@ .\strings\basic.jl:216 [inlined]
[2] codeunit
@ .\strings\string.jl:102 [inlined]
[3] getindex(s::String, i::Int64)
@ Base .\strings\string.jl:223
[4] top-level scope
@ REPL[112]:1
julia> str[1]
'A': ASCII/Unicode U+0041 (category Lu: Letter, uppercase)
julia> str[2]
'B': ASCII/Unicode U+0042 (category Lu: Letter, uppercase)
julia> str[3]
'C': ASCII/Unicode U+0043 (category Lu: Letter, uppercase)
julia> str[end]
'C': ASCII/Unicode U+0043 (category Lu: Letter, uppercase)
julia> str[2:3]
"BC"
▋〓〓特色〓〓▋str[k]与str[k:k]含义不同
julia> str[3]
'C': ASCII/Unicode U+0043 (category Lu: Letter, uppercase)
julia> str[3:3]
"C"
Unicode和UTF-8
####后续补充####
字符串拼接
####后续补充####
字符串替换
julia> "1+2=$(1+2)"
"1+2=3"
三重引号语法(说明:类似Python语言)
julia> str = """123 """
"123 "
常规运算符
####后续补充####
正则表达式
####后续补充####