プログラミング/julia/juliaの文法 のバックアップの現在との差分(No.1)

更新


  • 追加された行はこの色です。
  • 削除された行はこの色です。
[[プログラミング/julia]]

* ここを見ると大体分かる [#z7abd0ae]

http://nbviewer.jupyter.org/github/bicycle1885/Julia-Tutorial/blob/master/Julia%E9%AB%98%E9%80%9F%E3%83%81%E3%83%A5%E3%83%BC%E3%83%88%E3%83%AA%E3%82%A2%E3%83%AB.ipynb
- [[Julia高速チュートリアル>http://nbviewer.jupyter.org/github/bicycle1885/Julia-Tutorial/blob/master/Julia%E9%AB%98%E9%80%9F%E3%83%81%E3%83%A5%E3%83%BC%E3%83%88%E3%83%AA%E3%82%A2%E3%83%AB.ipynb]]
- [[Juliaクックブック>http://nbviewer.jupyter.org/github/bicycle1885/Julia-Tutorial/blob/master/Julia%E3%82%AF%E3%83%83%E3%82%AF%E3%83%96%E3%83%83%E3%82%AF.ipynb]]
- http://www.geocities.jp/m_hiroi/light/julia.html
- Introducing_Julia on wikibooks = https://en.wikibooks.org/wiki/Introducing_Julia
- Julia 練習帳 https://gist.github.com/t-nissie/261896dfc388da246ce3

* 変数のスコープを制限する [#k9280a65]

特に jupyter などで不用意にグローバル変数を作らないようにするために、
try end ブロックを使うと良い気がする。

 LANG:julia
 import Plots
 Plots.gr()
 try
   data = rand(10)
   Plots.plot(data)
 end
 
 # ここでは data は未定義

gist: https://gist.github.com/osamutake/fbbbd99c8f670335fa55afc0bfaa0438

あーと、これ、内部のエラーを無視しちゃうので良くないな。

もっと良い方法あるかしら。

* ネストした内包表現 [#jf95bef8]

大きな違いがある。

 LANG:julia
 #               行          列
 In : [(i,j) for i in [1,2], j in [2,3]]
 Out: 2×2 Array{Tuple{Int64,Int64},2}:
       (1, 2)  (1, 3)
       (2, 2)  (2, 3)
 
 #               外             中
 In : [(i,j) for i in [1,2] for j in [1,2]]
 Out: 4-element Array{Tuple{Int64,Int64},1}:
       (1, 2)
       (1, 3)
       (2, 2)
       (2, 3)

* 行列の書き方 [#se90f92b]

 LANG:julia
 In : [1 2; 3 4]
 Out: 2×2 Array{Int64,2}:
       1  3
       2  4
 
 In : [[1, 2] [3, 4]]
 Out: 2×2 Array{Int64,2}:
       1  3
       2  4
 
 In : [[1 2], [2 3]]
 Out: 2-element Array{Array{Int64,2},1}:
       [1 2]
       [2 3]

* 関数の機微 [#sb949f9c]

いろいろ勉強した:~
http://nbviewer.jupyter.org/gist/osamutake/5b6aa4f2cf74297e1bc4a6b22fd88a22

* コメント・質問 [#x4138e8f]

#article_kcaptcha


Counter: 5660 (from 2010/06/03), today: 1, yesterday: 0