# ---
# jupyter:
#   jupytext:
#     formats: ipynb,md
#     text_representation:
#       extension: .jl
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Julia 1.7.0-DEV
#     language: julia
#     name: julia-1.7
# ---

A = [1 2 3 4]

B = [1, 2, 3, 4]

A*B

A = [1, 2, 3, 4]'

A*B

C = [
    1 5
    2 6
    3 7
    4 8
]

A*C

v = [
    1
    2
]

A*C*v

x = 1:4
y = 1:3

X = [x for y in y, x in x]

Y = [y for y in y, x in x]

zero(X)

# +
module O

struct Foo{T}
    d::Dict{T}
end

function f(foo::Foo)
    d = foo.d
    for k in keys(d)
        println(k, ": ", d[k])
    end
end

end
# -

foo = O.Foo(Dict(:a => 1, :b => 2, :c => 3))

O.f(foo)

@code_warntype O.f(foo)

# +
module Q

struct Bar{K, V}
    d::Dict{K, V}
end

function g(bar::Bar)
    d = bar.d
    for k in keys(d)
        println(k, ": ", d[k])
    end
end

end
# -

bar = Q.Bar(Dict(:a => 1, :b => 2, :c => 3))

Q.g(bar)

@code_warntype Q.g(bar)

bar.d[:d] = 4

bar

baz = (d = bar.d,)

baz.d[:e] = 5
baz

bar

struct Qoo{T} a::T end
qoo = Qoo(Dict{Symbol, Int64}())

qoo.a[:a] = 1
qoo

qoo.a[:b] = 2
qoo

qux = (a = Int64[],)

push!(qux.a, 1, 2, 3)
qux

qux.a[2] = 999
qux

f(x) = if x < 0; "negative"; elseif x == 0; "zero"; else; "positive"; end

f(-1), f(0), f(1)

g(x) = if x < 0 "negative" elseif x == 0 "zero" else "positive" end

g(-1), f(0), f(1)

:(if a A elseif b B elseif c C else D end) |> Base.remove_linenums!

hoe = (a = 1, b = 2.0, c = "three")

typeof(hoe)



StarcoderdataJupyterScriptsDedupFiltered