2021/05/29 Python東海/JuliaTokaiミニ合同勉強会
@ OSC2021 Online/Nagoya
antimon2(後藤 俊介)
1年前
そろそろみんな Julia のことちゃんと知って欲しい
digraph TypeTree {
nodesep=1.0
node [fontname=Courier,shape=box,style=filled, fillcolor=gray95]
edge [arrowsize=0.8]
edge [arrowtail="empty" dir=back]
Any -> AbstractString
Any -> Number
Any -> _others
_others [label="...",shape=none,style=none,fillcolor=transparent]
AbstractString -> SomeStringSubtypes
AbstractString -> String
SomeStringSubtypes [label="...",shape=none,style=none,fillcolor=transparent]
Number -> Complex
Number -> Real
Real -> AbstractFloat
Real -> AbstractIrrational
Real -> Integer
Real -> Rational
AbstractFloat -> x1
x1 [label="...",shape=none,style=none,fillcolor=transparent]
AbstractFloat -> Float64
Integer -> Bool
Bool [label="...",shape=none,style=none,fillcolor=transparent]
Integer -> Signed
Signed -> Int
AbstractIrrational -> x2
x2 [label="...",shape=none,style=none,fillcolor=transparent]
Integer -> Unsigned
Unsigned -> x4
x4 [label="...",shape=none,style=none,fillcolor=transparent]
Signed -> x5
x5 [label="...",shape=none,style=none,fillcolor=transparent]
}
abstract type Point{T<:Real} end
struct Point2D{T} <: Point{T}
x::T
y::T
end
mutable struct MPoint2D{T} <: Point{T}
x::T
y::T
end
julia> double(x::Number) = 2x
double (generic function with 1 method)
julia> double(x::AbstractString) = x^2
double (generic function with 2 methods)
julia> double(π)
6.283185307179586
julia> double("😄")
"😄😄"
julia> @code_typed double(1)
CodeInfo(
1 ─ %1 = Base.mul_int(2, x)::Int64
└── return %1
) => Int64
julia> @code_typed double(9.9)
CodeInfo(
1 ─ %1 = Base.sitofp(Float64, 2)::Float64
│ %2 = Base.mul_float(%1, x)::Float64
└── return %2
) => Float64
julia> @code_typed double(π)
CodeInfo(
1 ─ return 6.283185307179586
) => Float64
そろそろみんな Julia のことを
もっと知りたくなってきましたよね?
ご清聴ありがとうございます。