티스토리 뷰
Packages¶
출처¶
https://github.com/JuliaComputing/JuliaBoxTutorials/tree/master/introductory-tutorials/intro-to-julia (github : JuliaComputing/JuliaBoxTutorials/introductory-tutorials/intro-to-julia/)
Topics:
함께보기¶
- 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/57 (07. Packages)(in English)
Julia는 오늘까지 1906개의 패키지가 등록되어있고, 이는 Julia 생태계에 큰 부분을 차지한다.
그럼에도 불구하고 패키지 생태계는 여전히 성장하고 있다. 특히, 다른 언어로의 first class 함수 호출을 통해 우수한 외래 함수 인터페이스를 제공한다. 예를 들어 PyCall 또는 Rcall을 사용하여 Python 또는 R로 쉽게 호출 할 수 있다.
즉, Julia 생태계가 완전히 성숙해질 때까지 기다릴 필요가 없으며, Julia로 이동한다고해서 다른 언어에서 좋아하는 패키지 / 라이브러리를 포기해야한다는 것을 의미하지는 않는다!
사용가능한 모든 패치지 목록은 아래 주소에 들어가서 확인 할 수 있다.
https://pkg.julialang.org/ 또는 https://juliaobserver.com/
지금부터 패키지를 어떻게 사용하는지 배운다.
주어진 Julia 설치에서 처음으로 패키지를 사용할 때, 패키지 관리자를 사용하여 패키지를 명시적으로 추가해야 한다.
using Pkg
Pkg.add("Example")
Julia를 사용할 때마다 (예를 들어, REPL에서 새 세션을 시작하거나, notebook에서 처음 열었을 때), using 키워드를 이용하여 패키지를 불러야 한다.
using Example
Example.jl의 소스코드에 보면(https://github.com/JuliaLang/Example.jl/blob/master/src/Example.jl), 아래의 함수가 아래와 같이 선언됐음을 볼 수 있다.
hello(who::String) = "Hello, $who"
Example을 불러왔으니, hello를 사용할 수 있다.
hello("it's me. I was wondering if after all these years you'd like to meet.")
이제 Colors 패키지를 불러와서 놀아보자.
Pkg.add("Colors")
using Colors
100가지의 다른 색으로 이루어진 팔레트를 생성해보자.
팔레트 = distinguishable_colors(100)
그리고, rand 명령어를 이용해서 무작위로 뽑힌 matrix를 만들어보자.
rand(팔레트, 3, 3)
다음 notebook에서, dataset을 plot 하는 새로운 패키지를 사용할 거다.
7.1¶
Primes 패키지를 불러오자. (소스코드 : https://github.com/JuliaMath/Primes.jl)
using Pkg
Pkg.add("Primes")
using Primes
@assert @isdefined Primes
7.2¶
primes 함수를 이용해서 1,000,000 보다 작은 소수들을 뽑아 소수목록에 저장하자.
소수목록 = primes(1000000)
@assert 소수목록 == primes(1000000)
'Flux in Julia > Learning Julia (Intro_to_Julia)' 카테고리의 다른 글
08. Plotting (한글) (0) | 2018.09.30 |
---|---|
08. Plotting (0) | 2018.09.30 |
07. Packages (0) | 2018.09.29 |
06. Functions (한글) (0) | 2018.09.27 |
06. Functions (0) | 2018.09.27 |