用法:
fill!(A, x)用值 x 填充數組 A 。如果x 是對象引用,則所有元素都將引用同一個對象。 fill!(A, Foo()) 將返回 A,其中填充了一次評估 Foo() 的結果。
例子
julia> A = zeros(2,3)
2×3 Matrix{Float64}:
 0.0  0.0  0.0
 0.0  0.0  0.0
julia> fill!(A, 2.)
2×3 Matrix{Float64}:
 2.0  2.0  2.0
 2.0  2.0  2.0
julia> a = [1, 1, 1]; A = fill!(Vector{Vector{Int}}(undef, 3), a); a[1] = 2; A
3-element Vector{Vector{Int64}}:
 [2, 1, 1]
 [2, 1, 1]
 [2, 1, 1]
julia> x = 0; f() = (global x += 1; x); fill!(Vector{Int}(undef, 3), f())
3-element Vector{Int64}:
 1
 1
 1相關用法
- Julia fill用法及代碼示例
- Julia filter!用法及代碼示例
- Julia filter用法及代碼示例
- Julia findfirst方法用法及代碼示例
- Julia findall方法用法及代碼示例
- Julia first方法用法及代碼示例
- Julia firstindex用法及代碼示例
- Julia findmax()用法及代碼示例
- Julia findlast方法用法及代碼示例
- Julia fieldnames用法及代碼示例
- Julia fieldname用法及代碼示例
- Julia fieldtypes用法及代碼示例
- Julia findnext方法用法及代碼示例
- Julia findprev方法用法及代碼示例
- Julia findmin()用法及代碼示例
- Julia findfirst()用法及代碼示例
- Julia findmax用法及代碼示例
- Julia first用法及代碼示例
- Julia findprev()用法及代碼示例
- Julia first()用法及代碼示例
- Julia finalizer用法及代碼示例
- Julia findlast()用法及代碼示例
- Julia findmin用法及代碼示例
- Julia findnext()用法及代碼示例
- Julia float方法用法及代碼示例
注:本文由純淨天空篩選整理自julialang.org 大神的英文原創作品 Base.fill! — Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
