Skip to content

Commit

Permalink
deploy: ee7f8a9
Browse files Browse the repository at this point in the history
  • Loading branch information
noelwelsh committed Sep 3, 2024
1 parent f16c11a commit 8db845e
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 44 deletions.
10 changes: 5 additions & 5 deletions animation/easing.html
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,12 @@ <h1 id="easing-functions" class="title">Easing Functions</h1>
.</span><span class="identifier">withRender</span><span>(</span><span class="identifier">r</span><span> =&gt; </span><span class="type-name">Image</span><span>.</span><span class="identifier">circle</span><span>(</span><span class="identifier">r</span><span>))
</span><span class="comment">// bubble: Reactor[Double] = Reactor(
// initial = 0.0,
// onMouseClickHandler = doodle.reactor.Reactor$$$Lambda$13877/0x00000001037bd840@4cef0c,
// onMouseMoveHandler = doodle.reactor.Reactor$$$Lambda$13878/0x00000001037be040@67973fb5,
// onTickHandler = doodle.reactor.Reactor$$$Lambda$13882/0x00000001037c7040@226c56f,
// onMouseClickHandler = doodle.reactor.Reactor$$$Lambda$13959/0x00000001037bd840@7118393b,
// onMouseMoveHandler = doodle.reactor.Reactor$$$Lambda$13960/0x00000001037be840@2ac8fb09,
// onTickHandler = doodle.reactor.Reactor$$$Lambda$13964/0x00000001037c7040@257f472a,
// tickRate = 100 milliseconds,
// renderHandler = repl.MdocSession$MdocApp$$Lambda$13884/0x00000001037c5840@241dd226,
// stopHandler = doodle.reactor.Reactor$$$Lambda$13883/0x00000001037c6040@434e6d26
// renderHandler = repl.MdocSession$MdocApp$$Lambda$13966/0x00000001037c5040@11e0aa95,
// stopHandler = doodle.reactor.Reactor$$$Lambda$13965/0x00000001037c6040@21019873
// )</span></code></pre>
<div class="flex flex-row justify-between">
<a class="pageNavigation" href="../sequences/">←Shapes, Sequences, and Stars</a> <a class="pageNavigation" href="reactor.html">Reactors→</a>
Expand Down
6 changes: 3 additions & 3 deletions flowers/functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -498,17 +498,17 @@ <h4 id="exercise-function-literals">Exercise: Function Literals</h4>
<div class="solution-body">
<p>The first function is</p>
<pre><code class="nohighlight"><span>(</span><span class="identifier">x</span><span>: </span><span class="type-name">Int</span><span>) =&gt; </span><span class="identifier">x</span><span> * </span><span class="identifier">x</span><span>
</span><span class="comment">// res10: Function1[Int, Int] = repl.MdocSession$MdocApp0$$Lambda$14187/0x00000001038b0840@7c2bbd90</span></code></pre>
</span><span class="comment">// res10: Function1[Int, Int] = repl.MdocSession$MdocApp0$$Lambda$14269/0x0000000103869040@776cecf4</span></code></pre>
<p>The second is</p>
<pre><code class="nohighlight"><span>(</span><span class="identifier">c</span><span>: </span><span class="type-name">Color</span><span>) =&gt; </span><span class="identifier">c</span><span>.</span><span class="identifier">spin</span><span>(</span><span class="number-literal">15</span><span>.</span><span class="identifier">degrees</span><span>)
</span><span class="comment">// res11: Function1[Color, HSLA] = repl.MdocSession$MdocApp0$$Lambda$14188/0x00000001038c0040@7046a5e0</span></code></pre>
</span><span class="comment">// res11: Function1[Color, HSLA] = repl.MdocSession$MdocApp0$$Lambda$14270/0x00000001038cf040@49c5aa8e</span></code></pre>
<p>The third is</p>
<pre><code class="nohighlight"><span>(</span><span class="identifier">image</span><span>: </span><span class="type-name">Image</span><span>) =&gt;
</span><span class="identifier">image</span><span>.</span><span class="identifier">beside</span><span>(</span><span class="identifier">image</span><span>.</span><span class="identifier">rotate</span><span>(</span><span class="number-literal">90</span><span>.</span><span class="identifier">degrees</span><span>))
.</span><span class="identifier">beside</span><span>(</span><span class="identifier">image</span><span>.</span><span class="identifier">rotate</span><span>(</span><span class="number-literal">180</span><span>.</span><span class="identifier">degrees</span><span>))
.</span><span class="identifier">beside</span><span>(</span><span class="identifier">image</span><span>.</span><span class="identifier">rotate</span><span>(</span><span class="number-literal">270</span><span>.</span><span class="identifier">degrees</span><span>))
.</span><span class="identifier">beside</span><span>(</span><span class="identifier">image</span><span>.</span><span class="identifier">rotate</span><span>(</span><span class="number-literal">360</span><span>.</span><span class="identifier">degrees</span><span>))
</span><span class="comment">// res12: Function1[Image, Image] = repl.MdocSession$MdocApp0$$Lambda$14189/0x00000001038c1040@2490c31</span></code></pre>
</span><span class="comment">// res12: Function1[Image, Image] = repl.MdocSession$MdocApp0$$Lambda$14271/0x00000001038cf840@3f9d1358</span></code></pre>
</div>
</div>
<div class="exercise">
Expand Down
16 changes: 8 additions & 8 deletions generative/flatmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,15 @@ <h4 id="randomness-and-randomness" class="section">Randomness and Randomness {-}
// c = FlatMapped(
// c = FlatMapped(
// c = Suspend(a = RDouble),
// f = cats.free.Free$$Lambda$14266/0x00000001038f5840@4da234c0
// f = cats.free.Free$$Lambda$14348/0x00000001038f6040@1f60bbaa
// ),
// f = cats.free.Free$$Lambda$14266/0x00000001038f5840@5930705a
// f = cats.free.Free$$Lambda$14348/0x00000001038f6040@66ca0d1b
// ),
// f = cats.free.Free$$Lambda$14266/0x00000001038f5840@10b1d7e8
// f = cats.free.Free$$Lambda$14348/0x00000001038f6040@622b19d2
// ),
// f = repl.MdocSession$MdocApp5$$Lambda$14283/0x0000000103905040@169ad7a7
// f = repl.MdocSession$MdocApp5$$Lambda$14365/0x000000010386d840@734bdd5a
// ),
// f = repl.MdocSession$MdocApp5$$Lambda$14286/0x0000000103910840@4a42e580
// f = repl.MdocSession$MdocApp5$$Lambda$14368/0x000000010386b840@69ec8572
// )</span></code></pre>
<p>which makes it clearer that we&#39;re generating three different circles.
&lt;/div&gt;</p>
Expand All @@ -528,17 +528,17 @@ <h4 id="colored-boxes" class="section">Colored Boxes {-}</h4>
</span><span class="type-name">Random</span><span>.</span><span class="identifier">double</span><span>.</span><span class="identifier">map</span><span>(</span><span class="identifier">x</span><span> =&gt; </span><span class="identifier">x</span><span>.</span><span class="identifier">turns</span><span>)
</span><span class="comment">// randomAngle: Free[[A &gt;: Nothing &lt;: Any] =&gt; RandomOp[A], Angle] = FlatMapped(
// c = Suspend(a = RDouble),
// f = cats.free.Free$$Lambda$14266/0x00000001038f5840@10aaee32
// f = cats.free.Free$$Lambda$14348/0x00000001038f6040@5ff8ff81
// )
</span><span>
</span><span class="keyword">val</span><span> </span><span class="identifier">randomColor</span><span>: </span><span class="type-name">Random</span><span>[</span><span class="type-name">Color</span><span>] =
</span><span class="identifier">randomAngle</span><span>.</span><span class="identifier">map</span><span>(</span><span class="identifier">hue</span><span> =&gt; </span><span class="type-name">Color</span><span>.</span><span class="identifier">hsl</span><span>(</span><span class="identifier">hue</span><span>, </span><span class="number-literal">0.7</span><span>, </span><span class="number-literal">0.7</span><span>))
</span><span class="comment">// randomColor: Free[[A &gt;: Nothing &lt;: Any] =&gt; RandomOp[A], Color] = FlatMapped(
// c = FlatMapped(
// c = Suspend(a = RDouble),
// f = cats.free.Free$$Lambda$14266/0x00000001038f5840@10aaee32
// f = cats.free.Free$$Lambda$14348/0x00000001038f6040@5ff8ff81
// ),
// f = cats.free.Free$$Lambda$14266/0x00000001038f5840@e3a6558
// f = cats.free.Free$$Lambda$14348/0x00000001038f6040@65278825
// )
</span><span>
</span><span class="keyword">def</span><span> </span><span class="declaration-name">coloredRectangle</span><span>(</span><span class="identifier">color</span><span>: </span><span class="type-name">Color</span><span>): </span><span class="type-name">Image</span><span> =
Expand Down
16 changes: 8 additions & 8 deletions generative/generative.html
Original file line number Diff line number Diff line change
Expand Up @@ -343,29 +343,29 @@ <h1 id="generative-art" class="title">Generative Art</h1>
</tbody>
</table>
<pre><code class="nohighlight"><span class="identifier">math</span><span>.</span><span class="identifier">random</span><span>
</span><span class="comment">// res0: Double = 0.6427896086532323
</span><span class="comment">// res0: Double = 0.11590444483753748
</span><span class="identifier">math</span><span>.</span><span class="identifier">random</span><span>
</span><span class="comment">// res1: Double = 0.7087462840661014</span></code></pre>
</span><span class="comment">// res1: Double = 0.5893809993089132</span></code></pre>
<p>Given <code>math.random</code> we could produce a method that returns a random <code>Angle</code> like so.</p>
<pre><code class="nohighlight"><span class="keyword">def</span><span> </span><span class="declaration-name">randomAngle</span><span>: </span><span class="type-name">Angle</span><span> =
</span><span class="identifier">math</span><span>.</span><span class="identifier">random</span><span>.</span><span class="identifier">turns</span><span>

</span><span class="identifier">randomAngle</span><span>
</span><span class="comment">// res2: Angle = Angle(0.22100981710708745)
</span><span class="comment">// res2: Angle = Angle(4.21248230846294)
</span><span class="identifier">randomAngle</span><span>
</span><span class="comment">// res3: Angle = Angle(2.8733864313204065)</span></code></pre>
</span><span class="comment">// res3: Angle = Angle(0.565703350100905)</span></code></pre>
<p>Why might we not want to do this? What principle does this break?</p>
<p>&lt;div class=&quot;solution&quot;&gt;
Generating random numbers in this way breaks substitution. Remember substitution says wherever we see an expression we should be able to substitute the value it evaluates to without changing the meaning of the program. Concretely, this means</p>
<pre><code class="nohighlight"><span class="keyword">val</span><span> </span><span class="identifier">result1</span><span> = </span><span class="identifier">randomAngle</span><span>
</span><span class="comment">// result1: Angle = Angle(3.3579227342350033)
</span><span class="comment">// result1: Angle = Angle(2.919447878400292)
</span><span class="keyword">val</span><span> </span><span class="identifier">result2</span><span> = </span><span class="identifier">randomAngle</span><span>
</span><span class="comment">// result2: Angle = Angle(4.3455812866304795)</span></code></pre>
</span><span class="comment">// result2: Angle = Angle(0.6172625269338852)</span></code></pre>
<p>and </p>
<pre><code class="nohighlight"><span class="keyword">val</span><span> </span><span class="identifier">result1</span><span> = </span><span class="identifier">randomAngle</span><span>
</span><span class="comment">// result1: Angle = Angle(1.4581806912472342)
</span><span class="comment">// result1: Angle = Angle(1.3237771085605212)
</span><span class="keyword">val</span><span> </span><span class="identifier">result2</span><span> = </span><span class="identifier">result1</span><span>
</span><span class="comment">// result2: Angle = Angle(1.4581806912472342)</span></code></pre>
</span><span class="comment">// result2: Angle = Angle(1.3237771085605212)</span></code></pre>
<p>should be the same program and clearly they are not.
&lt;/div&gt;</p>
<p>What should we do? Suffer the slings and arrows of outrageous computational models, or take arms against a sea of side-effects, and by opposing end them! There&#39;s really only one choice.</p>
Expand Down
6 changes: 3 additions & 3 deletions generative/random.html
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ <h1 id="randomness-without-effect" class="title">Randomness without Effect</h1>
// )</span></code></pre>
<p>No random numbers are actually created until we call the <code>run</code> method.</p>
<pre><code class="nohighlight"><span class="identifier">randomDouble</span><span>.</span><span class="identifier">run</span><span>
</span><span class="comment">// res0: Double = 0.3819358644150743</span></code></pre>
</span><span class="comment">// res0: Double = 0.07083496896965202</span></code></pre>
<p>The type <code>Random[Double]</code> indicates we have something that will produce a random <code>Double</code> when we <code>run</code> it. Just like with <code>Image</code> and <code>draw</code>, substitution holds with <code>Random</code> up until the point we call <code>run</code>.</p>
<p>Table Table generative:random shows some of the ways to construct <code>Random</code> values.</p>
<hr>
Expand Down Expand Up @@ -366,9 +366,9 @@ <h3 id="composing-random" class="section">Composing Random</h3>
</span><span class="type-name">Random</span><span>.</span><span class="identifier">double</span><span>.</span><span class="identifier">map</span><span>(</span><span class="identifier">x</span><span> =&gt; </span><span class="identifier">x</span><span>.</span><span class="identifier">turns</span><span>)</span></code></pre>
<p>When we <code>run</code> <code>RandomAngle</code> we can generate randomly created <code>Angle</code></p>
<pre><code class="nohighlight"><span class="identifier">randomAngle</span><span>.</span><span class="identifier">run</span><span>
</span><span class="comment">// res1: Angle = Angle(5.377266716596994)
</span><span class="comment">// res1: Angle = Angle(2.201818409364858)
</span><span class="identifier">randomAngle</span><span>.</span><span class="identifier">run</span><span>
</span><span class="comment">// res2: Angle = Angle(3.0049676253204924)</span></code></pre>
</span><span class="comment">// res2: Angle = Angle(1.4341691632574223)</span></code></pre>

<h3 id="exercises" class="section">Exercises {-}</h3>

Expand Down
16 changes: 8 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3229,14 +3229,14 @@ $c_Lcycles_Epicycles$.prototype.epicycleTwoWheels__T__V = (function(id) {
var runtime = $m_Lcats_effect_unsafe_IORuntime$().global__Lcats_effect_unsafe_IORuntime();
$f_Ldoodle_interact_animation_Transducer__animate__O__Ldoodle_interact_effect_AnimationRenderer__Ldoodle_effect_Renderer__Ldoodle_interact_algebra_Redraw__s_$less$colon$less__Lcats_effect_unsafe_IORuntime__V(this$19, frame, a, e, r, ev, runtime);
});
$c_Lcycles_Epicycles$.prototype.epicycleTwoWheels = (function(arg) {
var prep0 = $as_T(arg);
this.epicycleTwoWheels__T__V(prep0);
});
$c_Lcycles_Epicycles$.prototype.epicycle = (function(arg) {
var prep0 = $as_T(arg);
this.epicycle__T__V(prep0);
});
$c_Lcycles_Epicycles$.prototype.epicycleTwoWheels = (function(arg) {
var prep0 = $as_T(arg);
this.epicycleTwoWheels__T__V(prep0);
});
var $d_Lcycles_Epicycles$ = new $TypeData().initClass($c_Lcycles_Epicycles$, "cycles.Epicycles$", ({
Lcycles_Epicycles$: 1
}));
Expand Down Expand Up @@ -13134,14 +13134,14 @@ $c_Lpolygons_Creative$.prototype.curvygonExercise__T__V = (function(id) {
var runtime = $m_Lcats_effect_unsafe_IORuntime$().global__Lcats_effect_unsafe_IORuntime();
$f_Ldoodle_interact_animation_Transducer__animate__O__Ldoodle_interact_effect_AnimationRenderer__Ldoodle_effect_Renderer__Ldoodle_interact_algebra_Redraw__s_$less$colon$less__Lcats_effect_unsafe_IORuntime__V(this$22, frame, a, e, r, ev, runtime);
});
$c_Lpolygons_Creative$.prototype.starPolygonExercise = (function(arg) {
var prep0 = $as_T(arg);
this.starPolygonExercise__T__V(prep0);
});
$c_Lpolygons_Creative$.prototype.curvygonExercise = (function(arg) {
var prep0 = $as_T(arg);
this.curvygonExercise__T__V(prep0);
});
$c_Lpolygons_Creative$.prototype.starPolygonExercise = (function(arg) {
var prep0 = $as_T(arg);
this.starPolygonExercise__T__V(prep0);
});
$c_Lpolygons_Creative$.prototype.spiralExercise = (function(arg) {
var prep0 = $as_T(arg);
this.spiralExercise__T__V(prep0);
Expand Down
2 changes: 1 addition & 1 deletion main.js.map

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions part-two-introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,21 @@ <h1 id="part-two-introduction" class="title">Part Two: Introduction</h1>
<li>deepen our understanding of structural recursion, by using it in new contexts;</li>
<li>learn how to manipulate collections of data using standard methods <code>map</code>, <code>filter</code>, <code>flatMap</code>, and <code>foldLeft</code>;</li>
<li>define and use custom data structures of a particular kind known as algebraic data types; and</li>
<li>learn a model for understanding data known as boxes and arrows diagrams.</li>
<li>learn a model for understanding data layout in memory, known as boxes and arrows diagrams.</li>
</ol>
<p>We&#39;ll encounter these topics in the context of <em>exploratory data analysis</em>,
which, as the name suggests, is the process of exploring data in the hopes of finding interesting things within it.
Concretely, this means we&#39;ll be transforming data, visualizing it, and calculating statistics of it.
Exploratory data analysis is part of the larger field of <em>data science</em>, which lies at the intersection of computer science and statistics.
We will take a computational approach to statistics.
This means we&#39;ll get the computer, rather than fancy mathematics, to do the work for us,
which I think leads to a clearer understanding of these topics (particularly if you are a programmer!)</p>
<p>We&#39;ll encounter these topics in the context of <a href="https://en.wikipedia.org/wiki/Data_science">data science</a>.
Data science is the field concerned with finding interesting things in data.
This brings together elements of computing, statistics, and graphic design (in the form of visualization.)</p>
<p>Data science allows us to address questions about the world such as <strong>TODO: insert examples</strong>
In this part we&#39;ll use a variety of data sets to explore these questions.
If you have particular data you&#39;re interested in exploring, I encourage you to do so in this part.
There is no better way to learn than to work on questions that are meaningful to you.</p>
<p>This part assumes little experience with statistics.
When we meet statistcal concepts,
we&#39;ll approach them from a computational, rather than mathematical, perspective.
This means we&#39;ll get the computer to do the work for us,
and we&#39;ll avoid a lot fancy mathematics that is typically found in statistics courses.
I think this leads to a clearer understanding of these topics (particularly if you are a programmer!)</p>

<h2 id="setup" class="section">Setup</h2>
<p>To work through this part of the book, use the <a href="https://github.com/creativescala/creative-scala-data-template">creative-scala-data-template</a> from Github.</p>
Expand Down

0 comments on commit 8db845e

Please sign in to comment.