Skip to content

Instantly share code, notes, and snippets.

@phasetr
Created September 1, 2021 13:00
Show Gist options
  • Save phasetr/1ef4e4f797e9b4966ed9586944b5e4dc to your computer and use it in GitHub Desktop.
Save phasetr/1ef4e4f797e9b4966ed9586944b5e4dc to your computer and use it in GitHub Desktop.
勉強会で作った内容
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "08325818",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4-element Vector{Float64}:\n",
" -1.1\n",
" 0.0\n",
" 3.6\n",
" -7.2"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = [ -1.1, 0.0, 3.6, -7.2 ]"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "b2b6241f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2×3 Matrix{Int64}:\n",
" 1 2 3\n",
" 1 3 3"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = [\n",
" 1 2 3\n",
" 1 3 3\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "d23c1ae0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4-element Vector{Float64}:\n",
" -1.1\n",
" 0.0\n",
" 3.6\n",
" -7.2"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y = [ -1.1; 0.0; 3.6; -7.2 ]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "6fd8fe59",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1, 2)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b = (1, 2)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "d5302a43",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x[begin]"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "5cde9fd0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-1.1"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y[begin]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "ffbb0593",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-7.2"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y[end]"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "5ddb8f29",
"metadata": {},
"outputs": [],
"source": [
"x=[1,-2]'; y=[1,1]';"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "0fb5b357",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2×2 Matrix{Int64}:\n",
" 1 -2\n",
" 1 1"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"z = [ x; y ]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "993aba67",
"metadata": {},
"outputs": [
{
"ename": "LoadError",
"evalue": "ArgumentError: number of columns of each array must match (got (2, 3))",
"output_type": "error",
"traceback": [
"ArgumentError: number of columns of each array must match (got (2, 3))",
"",
"Stacktrace:",
" [1] _typed_vcat(#unused#::Type{Int64}, A::Tuple{LinearAlgebra.Adjoint{Int64, Vector{Int64}}, LinearAlgebra.Adjoint{Int64, Vector{Int64}}})",
" @ Base .\\abstractarray.jl:1553",
" [2] typed_vcat",
" @ .\\abstractarray.jl:1567 [inlined]",
" [3] vcat(::LinearAlgebra.Adjoint{Int64, Vector{Int64}}, ::LinearAlgebra.Adjoint{Int64, Vector{Int64}})",
" @ SparseArrays C:\\buildbot\\worker\\package_win64\\build\\usr\\share\\julia\\stdlib\\v1.6\\SparseArrays\\src\\sparsevector.jl:1120",
" [4] top-level scope",
" @ In[10]:2",
" [5] eval",
" @ .\\boot.jl:360 [inlined]",
" [6] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)",
" @ Base .\\loading.jl:1094"
]
}
],
"source": [
"x=[1,-2]'; y=[1,1,0]';\n",
"z = [ x; y ]"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "95bd2fa0",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"2×2 Matrix{Int64}:\n",
" 1 -2\n",
" 1 1"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x=[1,-2]'; y=[1,1]';\n",
"z = [ x; y ]"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "eb4ce567",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1×2 adjoint(::Vector{Int64}) with eltype Int64:\n",
" 1 -2"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x=[1,-2]'"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "9640c266",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"2-element Vector{Int64}:\n",
" 1\n",
" -2"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x=[1,-2]"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "c2fc2ce8",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"([1, -2], [1, 1, 0])"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x=[1,-2]; y=[1,1,0];\n",
"z = ( x, y )"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "8ea833f0",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"2-element Vector{Vector{Int64}}:\n",
" [1, -2]\n",
" [1, 1, 0]"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"z = [ x, y ]"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "cb35b21c",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"3-element Vector{Int64}:\n",
" 4\n",
" 3\n",
" 0"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = [ 9, 4, 3, 0, 5 ];\n",
"y = x[2:4]"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "a707b907",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"3\n",
"5\n"
]
}
],
"source": [
"for i in 1:2:5\n",
" println(i)\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "1c6e9875",
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/plain": [
"5-element Vector{Int64}:\n",
" 5\n",
" 0\n",
" 3\n",
" 4\n",
" 9"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x[end:-1:begin]"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "6935174c",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"5-element Vector{Int64}:\n",
" 5\n",
" 0\n",
" 3\n",
" 4\n",
" 9"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"reverse(x)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "9d29db19",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"3-element Vector{Vector{Float64}}:\n",
" [1.0, 0.0]\n",
" [1.0, -1.0]\n",
" [0.0, 1.0]"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = [ 1.0, 0 ]; y = [ 1.0, -1.0 ]; z = [ 0, 1.0];\n",
"list = [ x, y, z ]"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "a50ce5a9",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"3-element Vector{Vector{Float64}}:\n",
" [1.0, 0.0]\n",
" [1.0, -1.0]\n",
" [0.0, 1.0]"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = [ 1.0, 0 ]; y = [ 1.0, -1.0 ]; z = [ 0, 1.0];\n",
"list = [ x, y, z ]"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "07b81605",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"3-element Vector{Vector{Float64}}:\n",
" [1.0, 0.0]\n",
" [1.0, -1.0]\n",
" [0.0, 1.0]"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[x, y, z]"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "b266cef3",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"6-element Vector{Float64}:\n",
" 1.0\n",
" 0.0\n",
" 1.0\n",
" -1.0\n",
" 0.0\n",
" 1.0"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[x; y; z]"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "6ad08bf0",
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1.0\n",
"[1.0, 0.0]\n"
]
}
],
"source": [
"x = [ 1.0, 0 ]; y = [ 1.0, -1.0 ]; z = [ 0, 1.0];\n",
"list = [ x, y, z ]\n",
"println(list[1][1])\n",
"println(list[1,1])"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "3d4ea8d8",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"3-element Vector{Int64}:\n",
" 0\n",
" 0\n",
" 0"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"zeros(Int, 3)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "f49e9aab",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
":circle"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
":circle"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "ca07bda1",
"metadata": {},
"outputs": [],
"source": [
"w = [1,2,2]; z = [1,2,3];"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "899f767c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element BitVector:\n",
" 1\n",
" 1\n",
" 0"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"w .== z"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.6.1",
"language": "julia",
"name": "julia-1.6"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment