You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: notebooks/week1/abstraction.jl
+49-49Lines changed: 49 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,15 @@ macro bind(def, element)
13
13
end
14
14
end
15
15
16
+
# ╔═╡ da1d65a0-ec42-11ea-0141-334c9eeeb035
17
+
begin
18
+
using Pkg
19
+
Pkg.activate(mktempdir())
20
+
Pkg.add(["PlutoUI", "Images", "ImageMagick"])
21
+
using PlutoUI
22
+
using Images
23
+
end
24
+
16
25
# ╔═╡ 5ef51c3a-70a7-11eb-2023-31113399a57f
17
26
html"""
18
27
<div style="
@@ -85,17 +94,6 @@ The goal of this section is to introduce you to the notion of abstraction. You c
85
94
Before we get lost talking about the foundations of number theory, I will present you with a few examples that represent one to me.
86
95
"
87
96
88
-
# ╔═╡ 0504ac94-70ee-11eb-1c4e-977d9e7d35c9
89
-
one = [
90
-
1,
91
-
1.0,
92
-
"one",
93
-
1//1,
94
-
oneimage,
95
-
[10; 01],
96
-
corgi,
97
-
]
98
-
99
97
# ╔═╡ 6fcac482-70ee-11eb-0b80-ff41c708053b
100
98
md"Each of the items in this list is a specific, or **_specialized_** representation of _one_:
101
99
1. as an integer
@@ -111,9 +109,6 @@ Of course, these are just a few examples of _one_. People have been representing
111
109
The difference between these ones to me is clear. In fact, I just articulated it to you. Now, let's turn to how a computer sees _one_ differently based on what I type.
112
110
"
113
111
114
-
# ╔═╡ 0b1668ba-ec42-11ea-3e50-ed97c5b17ced
115
-
computer_ones =typeof.(one)
116
-
117
112
# ╔═╡ 9ebc079a-70f0-11eb-07d9-f9e80f3f4584
118
113
md"So to a computer, all of these are different types."
119
114
@@ -122,26 +117,6 @@ md"### What is a collection of _one_s?
122
117
123
118
Now, I want to make a collection of ones for some reason. Below is a way for you to experiment building this collection with different _one_s. As you do this experiment, I want you to look at what stays in the same in the Julia output, and what doesn't."
Before we even look at the output, I am amazed that this code even ran. Are you telling me that the computer doesn't care which _one_ I am using in my array?
not_defined(variable_name) = Markdown.MD(Markdown.Admonition("danger", "Oopsie!", [md"Make sure that you define a variable called **$(Markdown.Code(string(variable_name)))**"]))
853
806
807
+
# ╔═╡ e3394c8a-edf0-11ea-1bb8-619f7abb6881
808
+
if!@isdefined(create_bar)
809
+
not_defined(:create_bar)
810
+
else
811
+
let
812
+
result =create_bar()
813
+
ifismissing(result)
814
+
still_missing()
815
+
elseifisnothing(result)
816
+
keep_working(md"Did you forget to write `return`?")
817
+
elseif!(result isa Vector) ||length(result) !=100
818
+
keep_working(md"The result should be a `Vector` with 100 elements.")
0 commit comments