Julia eltype

eltype 自己理解就是 每个元素的类型

julia> 1f0
1.0f0

julia> typeof(1f0)
Float32

julia> fill(1f0, (2,2))
2×2 Array{Float32,2}:
 1.0  1.0
 1.0  1.0
 
julia> eltype(fill(1f0, (2,2)))
Float32
help?> eltype
search: eltype fieldtype

  eltype(type)

  Determine the type of the elements generated by iterating a collection of
  the given type. For dictionary types, this will be a Pair{KeyType,ValType}.
  The definition eltype(x) = eltype(typeof(x)) is provided for convenience so
  that instances can be passed instead of types. However the form that accepts
  a type argument should be defined for new types.

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  julia> eltype(fill(1f0, (2,2)))
  Float32
  
  julia> eltype(fill(0x1, (2,2)))
  UInt8
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值