Julia(未來可能替代Python與R語言) 其他函數

關注微信公共號:小程在線

關注CSDN博客:程志偉的博客

 

1.time()

這個時間是從1970年1月1日0時開始的,距今現在的時間

julia> time()
1.592537707458e9

 

2.條件語句

if-else語句

julia> x =5; y = 89;z=7;a=0;

julia> if x>=1
       y += 30
       else
       a += 100
       end;

julia> show([y,a])
[119, 0]
julia> if x ==5
       z += 7
       if y < 0
       a +=100
       else
       a -= 100
       end
       end;

julia> show([z,a])
[14, -100]
julia> x =0; c =0;d=0;

julia> if x>0
       c +=1
       elseif x==0
       d +=1
       else
       println("X IS NO")
       end
1

julia> show([c,d])
[0, 1]
julia> x = 123;

julia> if x>0
       "X is YES"
       else
       "X is NO"
       end
"X is YES"

 

三元運算形式

julia> x =456;result = x>0 ? "X is Yes" : "X is No"
"X is Yes"

 

3.string()

string()可以將數字轉化爲字符串

julia> string(214)
"214"

 

string可以將多個變量轉化爲字符串拼接在一起

julia> string(214,true,"SNE",53.6)
"214trueSNE53.6"

 

4.map()

map(fun,arr):fun表示一個函數,arr表示一個數組

julia> show(map(length,["856","52","w","length"]))

 

5.version

julia> VERSION
v"1.4.2"

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章