MATLAB移民のためのJulia tips

MATLAB移民のためのJulia tips

何も考えずに速く計算できないのならば、何もやりたくない。

配列から文字列、文字列から配列への変換 (convert array to string, string to array)

配列を文字列に変換

joinを使う:

a = ["a","b","c","d","e"]
join(a, " - ", " and ")

"a - b - c - d and e"

  • joinのオプションを2つ指定すると、最後の区切りだけ2つ目のものになる。
  • 3つ以上はたぶん指定不可。

文字列を配列に変換

splitを使う:

a = "a b c d e"
u = split(a, " ")

5-element Array{SubString{ASCIIString},1}:

"a"
"b"
"c"
"d"
"e"