在 Julia 中创建向量 – vect() 方法
vect()
是 julia 中的一个内置函数,用于创建一个以传递的元素作为参数的向量。
Syntax: vect(X…)
Parameters:
- X: Specified elements.
Returns: It returns the created vector formed by the elements passed as parameter.
示例 1:
# Julia program to illustrate
# the use of vect() method
# Getting the created vector formed
# by the elements passed as parameter
println(Base.vect(1, 2, 3, 4))
println(Base.vect(1.0, 2.1, 3.2, 4.5))
println(Base.vect("a", "b", "c"))
println(Base.vect("ab", "bc", "cd"))
输出:
示例 2:
# Julia program to illustrate
# the use of vect() method
# Getting the created vector formed
# by the elements passed as parameter
println(Base.vect(UInt8(6), 2, 1))
println(Base.vect(UInt8(1), 3.6, 1//2))
println(Base.vect(UInt8(1), 2.5, 8.0))
println(Base.vect(UInt8(5), UInt16(25), UInt32(198)))
输出: