[Julia] 07. Packages


Packages


Juliaはすでに2000以上のパッケージを登録しており、現在も新しいパッケージを作成しています.それだけでなく、python、Rに存在するパッケージをPyCall、Rcallなどでロードすることもできます.
パッケージを初めて使用するには、パッケージマネージャに登録する必要があります.
using Pkg
Pkg.add("Example")
using Example
┌ Info: Precompiling Example [7876af07-990d-54b4-ab0e-23690620f79a]
└ @ Base loading.jl:1278
hello("it's me. I was wondering if after all these years you'd like to meet.")
"Hello, it's me. I was wondering if after all these years you'd like to meet."
Pkg.add("Colors")
using Colors
┌ Info: Precompiling Colors [5ae59095-9a9b-59fe-a467-6f913c188581]
└ @ Base loading.jl:1278
palette = distinguishable_colors(100)
rand(palette, 3, 3)

Exercises

# 7.1
Pkg.add("Primes")
using Primes
# 7.2
primes_list = primes(1000000)
78498-element Array{Int64,1}:
      2
      3
      5
      7
     11
     13
     17
     19
     23
     29
     31
     37
     41
      ⋮
 999809
 999853
 999863
 999883
 999907
 999917
 999931
 999953
 999959
 999961
 999979
 999983