一、Array的過濾 模式: list =[-3,-2,-1,0,1,2,3,4,5,6,7,8];a =[x^2+2*x+3 for x in list ]; # 不過濾b =[x^2+2*x+3 for x in list if x>0] # 後置過濾c =[y =x>0? x^2+2*x+3 : 0 for x in list ] # 前置過濾d =[y =x>2? x^2+2*x+3 : 2*x for x in list if x>0 ] #
eval不管是在matlab,python,js等語言中,還是在Julia中,都有十分廣泛的應用。有些是無法替代的,沒有eval,可能還真玩不轉。 下面主要講一下Julia的eval: 一、如何把using放在函數中。 using 是不允許直接放在函數中的,不信你試試。但是,比如,我不同的情況需要調用不同的庫,這個時侯如何處理,那麼請eval出場是什麼必要的事情。否則,真不知如何解決。 比如,一個畫出策略出PL的函數: 需要注意的是,變數前加一個$。 function
https://github.com/josephmisiti/awesome-machine-learning#julia-nlp Julia General-Purpose Machine Learning MachineLearning - Julia Machine Learning library MLBase - A set of functions to support the development of machine learning algorithms
做策略時,經常會畫到時間順序圖表,PyPlot庫中有一個plot_date函數,可以滿足這個需求。 函數: plot_date(x, y, fmt='bo', tz=None, xdate=True, ydate=False, **kwargs) 其中,x and/or y can be a sequence of dates represented as float days since 0001-01-01 UTC. 具體應用如下:
Rust從1.13版對語言進行了一些擴充,包括期待已久的?操作符。今天重點來談談。操作符。 最初,加入了一個新的操作符?,是為了簡化Result fn read_username_from_file() -> Result<String, io::Error> { let f = File::open("username.txt"); let mut f = match f { Ok(file) => file,
逆序輸出,本來是很簡單的。 比如:對於一個vector(), 可以用reverse(). let mut r = [1, 2, 3]; r.reverse(); # r =[3,2,1] let mut s = ["a","b","c"]; s.reverse(); # s =["c","b","a"] 但需要注意!!!! let mut s = ["a","b","c"]; # [1,2,3]也一樣。 let vs =s.reverse();