티스토리 뷰
Packages¶
Reference¶
https://github.com/JuliaComputing/JuliaBoxTutorials/tree/master/introductory-tutorials/intro-to-julia (github : JuliaComputing/JuliaBoxTutorials/introductory-tutorials/intro-to-julia/)
Topics:
Series¶
- http://deepstat.tistory.com/45 (01. Getting started)(in English)
- http://deepstat.tistory.com/46 (01. Getting started(한글))
- http://deepstat.tistory.com/47 (02. Strings)(in English)
- http://deepstat.tistory.com/48 (02. Strings(한글))
- http://deepstat.tistory.com/49 (03. Data structures)(in English)
- http://deepstat.tistory.com/50 (03. Data structures(한글))
- http://deepstat.tistory.com/51 (04. Loops)(in English)
- http://deepstat.tistory.com/52 (04. Loops(한글))
- http://deepstat.tistory.com/53 (05. Conditionals)(in English)
- http://deepstat.tistory.com/54 (05. Conditionals(한글))
- http://deepstat.tistory.com/55 (06. Functions)(in English)
- http://deepstat.tistory.com/56 (06. Functions(한글))
- http://deepstat.tistory.com/58 (07. Packages(한글))
Julia has 1906 registered packages today, making packages a huge part of the Julia ecosystem.
Even so, the package ecosystem still has some growing to do. Notably, we have first class function calls to other languages, providing excellent foreign function interfaces. We can easily call into python or R, for example, with PyCall or Rcall.
This means that you don't have to wait until the Julia ecosystem is fully mature, and that moving to Julia doesn't mean you have to give up your favorite package/library from another language!
To see all available packages, check out
https://pkg.julialang.org/ or https://juliaobserver.com/
For now, let's learn how to use a package.
The first time you use a package on a given Julia installation, you need to use the package manager to explicitly add it:
using Pkg
Pkg.add("Example")
Every time you use Julia (start a new session at the REPL, or open a notebook for the first time, for example), you load the package with the using keyword
using Example
In the source code of Example.jl at https://github.com/JuliaLang/Example.jl/blob/master/src/Example.jl we see the following function declared
hello(who::String) = "Hello, $who"
Having loaded Example, we should now be able to call hello
hello("it's me. I was wondering if after all these years you'd like to meet.")
Now let's play with the Colors package
Pkg.add("Colors")
using Colors
Let's create a palette of 100 different colors
palette = distinguishable_colors(100)
and then we can create a randomly checkered matrix using the rand command
rand(palette, 3, 3)
In the next notebook, we'll use a new package to plot datasets.
7.1¶
Load the Primes package (source code at https://github.com/JuliaMath/Primes.jl).
using Pkg
Pkg.add("Primes")
using Primes
@assert @isdefined Primes
7.2¶
Verify that you can now use the function primes to grab all prime numbers under 1,000,000 and store it in variable primes_list
primes_list = primes(1000000)
@assert primes_list == primes(1000000)
'Flux in Julia > Learning Julia (Intro_to_Julia)' 카테고리의 다른 글
08. Plotting (0) | 2018.09.30 |
---|---|
07. Packages (한글) (0) | 2018.09.29 |
06. Functions (한글) (0) | 2018.09.27 |
06. Functions (0) | 2018.09.27 |
05. Conditionals (한글) (0) | 2018.09.18 |