Skip to content

Commit

Permalink
lab7
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMrGhostman committed Nov 7, 2024
1 parent 9ec30d1 commit d83411c
Showing 1 changed file with 30 additions and 171 deletions.
201 changes: 30 additions & 171 deletions interactive_notebooks/lab7/lab7_empty.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,71 +22,27 @@
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"x = 1"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x + 1 = 2\n"
]
},
{
"data": {
"text/plain": [
"2"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"@show x + 1 "
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x + 1 = 2\n"
]
},
{
"data": {
"text/plain": [
"2"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"let y = x + 1 # creates a temporary local variable\n",
" println(\"x + 1 = \", y)\n",
Expand All @@ -96,53 +52,19 @@
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x = 3 = 3\n"
]
},
{
"data": {
"text/plain": [
"3"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# assignments should create the variable\n",
"@show x = 3"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x = 2 = 2\n"
]
},
{
"data": {
"text/plain": [
"2"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"let y = x = 2 \n",
" println(\"x = 2 = \", y)\n",
Expand All @@ -152,19 +74,9 @@
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"x # should be equal to 2"
]
Expand All @@ -178,19 +90,9 @@
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"@myshow (macro with 1 method)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"macro myshow(ex)\n",
" quote\n",
Expand All @@ -209,26 +111,9 @@
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"xx = 1 + 1 = 2\n"
]
},
{
"data": {
"text/plain": [
"2"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"@myshow xx = 1 + 1\n",
"xx # should be defined"
Expand All @@ -249,25 +134,9 @@
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"quote\n",
" Base.println(\"x + 1 = \", Base.repr(begin\n",
" \u001b[90m#= show.jl:1181 =#\u001b[39m\n",
" local var\"#65#value\" = x + 1\n",
" end))\n",
" var\"#65#value\"\n",
"end"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"@macroexpand @show x + 1"
]
Expand All @@ -282,19 +151,9 @@
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"run_polynomial (generic function with 1 method)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"function run_polynomial(n, a, x)\n",
" for _ in 1:n\n",
Expand Down

0 comments on commit d83411c

Please sign in to comment.