julia 编程语言_Julia编程语言中的变量
julia 編程語言
Julia中的變量 (Variables in Julia)
Just like other programming languages, in Julia variables are the name of memory blocks that are associated (or bound) to a value. It is useful when a value to be stored or to be accessed in/from memory locations.
就像其他編程語言一樣,在Julia中,變量是與值關(guān)聯(lián)(或綁定)的內(nèi)存塊的名稱。 在存儲位置或從存儲位置訪問或存儲值時很有用。
聲明變量的規(guī)則 (Rules to declare a variable)
A variable name must be started with:
變量名稱必須以以下內(nèi)容開頭:
- a letter (A to Z/a to z), or
- an underscore (_), or
- a subset of Unicode code points greater than 00A0
A variable name must not contain any special character (exception some of the character in special cases).
變量名不得包含任何特殊字符(特殊情況下某些字符除外)。
Digits (0-9) can be used in the variable name (not as a starting letter)
可以在變量名稱中使用數(shù)字(0-9)(不能用作起始字母)
變量命名約定 (Variable naming conventions)
For a better programming style in Julia, we should remember the following points,
為了使用Julia更好的編程風(fēng)格,我們應(yīng)該記住以下幾點,
Variable names should be in lowercase
變量名應(yīng)小寫
Instead of using space as a word separator in variable names, we should use underscore (_).
不要使用空格作為變量名稱中的單詞分隔符,而應(yīng)使用下劃線(_)。
Types names and Modules names should be started with a capital letter (uppercase), if the variable name is long (used multiple words) then for word separation, we should not use underscore (-), instead of using underscore (_) use the first letter as capital (uppercase) of each word.
類型名稱和模塊名稱應(yīng)以大寫字母開頭(大寫),如果變量名稱很長(使用多個單詞),則為了進(jìn)行單詞分隔,我們不應(yīng)使用下劃線(-),而應(yīng)使用下劃線(_)使用第一個字母作為每個單詞的大寫(大寫)。
Functions and macros names should be in lowercase without word separation.
函數(shù)和宏的名稱應(yīng)為小寫字母,且不要單詞分隔。
聲明變量并賦值 (Declaring a variable and Assigning values)
Since Julia does not support data type with the global variables, the variable automatically detects its type based on the given values.
由于Julia不支持全局變量的數(shù)據(jù)類型,因此變量會根據(jù)給定的值自動檢測其類型。
Example:
例:
# variables a = 10 b = 10.23 c = 'c' d = "Hello"# printing the values println("Initial values...") println("a: ", a) println("b: ", b) println("c: ", c) println("d: ", d)# updating the values a = a + 10 b = b + 12 c = 'x' d = "world!"# printing the values println("After updating...") println("a: ", a) println("b: ", b) println("c: ", c) println("d: ", d)Output
輸出量
Initial values... a: 10 b: 10.23 c: c d: Hello After updating... a: 20 b: 22.23 c: x d: world!Reference: https://docs.julialang.org
參考: https : //docs.julialang.org
翻譯自: https://www.includehelp.com/julia/variables.aspx
julia 編程語言
總結(jié)
以上是生活随笔為你收集整理的julia 编程语言_Julia编程语言中的变量的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: css scroll属性_CSS中的sc
- 下一篇: mcq 队列_人工智能搜索问题能力问题解