АО
Size: a a a
АО
VM
АО
АО
pkg> activate <Название пакета>
pkg> add LinearAlgebra
VM
VM
pkg> activate <Название пакета>
pkg> add LinearAlgebra
KT
KT
struct Foo{T}
v :: Vector{T}
# other fields
endKT
iterate(foo :: Foo) ... ?KT
iterate(foo :: Foo) return iterate(foo.v) endKT
function iterate(foo :: Foo, state)
return iterate(foo.v, state)
end
АО
iterate(f::Foo, s = iterate(f.v)) = iterate(f.v, s)VG
АО
KT
KT
abstract type Foo endKT
Real <: Foo == trueАО
АО
Real <: Foo == true?abstract type AbstractFoo end
struct Foo{T} <: AbstractFoo
x::T
end
Base.:*(x::T, y::T) where {T <: AbstractFoo} = T(x.x * y.x)
mypow2(x) = x*x
mypow2(Foo(2)) # Foo{Int64}(4)
mypow2(2) # 4