Skip to content

Commit

Permalink
deploy: 6e8dbdf
Browse files Browse the repository at this point in the history
  • Loading branch information
noelwelsh committed Aug 22, 2024
1 parent 4f4e4ff commit 52c9a77
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
10 changes: 5 additions & 5 deletions animation/easing.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,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$14406/0x0000000103c01840@25ec50be,
// onMouseMoveHandler = doodle.reactor.Reactor$$$Lambda$14407/0x0000000103c02040@47a64fc1,
// onTickHandler = doodle.reactor.Reactor$$$Lambda$14411/0x0000000103c05840@44c363bc,
// onMouseClickHandler = doodle.reactor.Reactor$$$Lambda$14410/0x0000000103c01840@5c14478b,
// onMouseMoveHandler = doodle.reactor.Reactor$$$Lambda$14411/0x0000000103c02840@70f2ca19,
// onTickHandler = doodle.reactor.Reactor$$$Lambda$14415/0x0000000103c05840@43e9987,
// tickRate = 100 milliseconds,
// renderHandler = repl.MdocSession$MdocApp$$Lambda$14413/0x0000000103c07040@51370e0,
// stopHandler = doodle.reactor.Reactor$$$Lambda$14412/0x0000000103c06840@209aff0f
// renderHandler = repl.MdocSession$MdocApp$$Lambda$14417/0x0000000103c07840@3a7d23dd,
// stopHandler = doodle.reactor.Reactor$$$Lambda$14416/0x0000000103c06840@1bece24f
// )</span></code></pre>
<div class="flex flex-row justify-between">
<a class="pageNavigation" href="reactor.html">←Reactors</a> <a class="pageNavigation" href="../sequences/">Shapes, Sequences, and Stars→</a>
Expand Down
6 changes: 3 additions & 3 deletions flowers/functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,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$14731/0x0000000103d15040@3174d2ad</span></code></pre>
</span><span class="comment">// res10: Function1[Int, Int] = repl.MdocSession$MdocApp0$$Lambda$14735/0x0000000103d15040@7fecb19d</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$14732/0x0000000103d14040@6609d767</span></code></pre>
</span><span class="comment">// res11: Function1[Color, HSLA] = repl.MdocSession$MdocApp0$$Lambda$14736/0x0000000103d14840@a09afff</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$14733/0x0000000103d13840@2cbbd1a</span></code></pre>
</span><span class="comment">// res12: Function1[Image, Image] = repl.MdocSession$MdocApp0$$Lambda$14737/0x0000000103d13840@3e00f226</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 @@ -367,15 +367,15 @@ <h4 id="randomness-and-randomness" class="section">Randomness and Randomness {-}
// c = FlatMapped(
// c = FlatMapped(
// c = Suspend(a = RDouble),
// f = cats.free.Free$$Lambda$14804/0x0000000103d1c840@4de161a5
// f = cats.free.Free$$Lambda$14808/0x0000000103d31840@1526fb1d
// ),
// f = cats.free.Free$$Lambda$14804/0x0000000103d1c840@4db0cfdf
// f = cats.free.Free$$Lambda$14808/0x0000000103d31840@5ccde882
// ),
// f = cats.free.Free$$Lambda$14804/0x0000000103d1c840@1dfd3d1d
// f = cats.free.Free$$Lambda$14808/0x0000000103d31840@24cd1487
// ),
// f = repl.MdocSession$MdocApp5$$Lambda$14821/0x0000000103d4d040@fce2d26
// f = repl.MdocSession$MdocApp5$$Lambda$14825/0x0000000103d4a840@50c64ce
// ),
// f = repl.MdocSession$MdocApp5$$Lambda$14824/0x0000000103d4a840@49649933
// f = repl.MdocSession$MdocApp5$$Lambda$14828/0x0000000103d4c840@27508961
// )</span></code></pre>
<p>which makes it clearer that we&#39;re generating three different circles.
&lt;/div&gt;</p>
Expand All @@ -396,17 +396,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$14804/0x0000000103d1c840@2e179f7
// f = cats.free.Free$$Lambda$14808/0x0000000103d31840@146aecf1
// )
</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$14804/0x0000000103d1c840@2e179f7
// f = cats.free.Free$$Lambda$14808/0x0000000103d31840@146aecf1
// ),
// f = cats.free.Free$$Lambda$14804/0x0000000103d1c840@7600a963
// f = cats.free.Free$$Lambda$14808/0x0000000103d31840@58cfabd7
// )
</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 @@ -203,29 +203,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.6856738988748449
</span><span class="comment">// res0: Double = 0.7821066444644448
</span><span class="identifier">math</span><span>.</span><span class="identifier">random</span><span>
</span><span class="comment">// res1: Double = 0.5229102756056774</span></code></pre>
</span><span class="comment">// res1: Double = 0.9806817367551008</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(4.9652921514142525)
</span><span class="comment">// res2: Angle = Angle(3.9531235922054853)
</span><span class="identifier">randomAngle</span><span>
</span><span class="comment">// res3: Angle = Angle(5.396033606864073)</span></code></pre>
</span><span class="comment">// res3: Angle = Angle(0.6921591703254422)</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(2.429367711400353)
</span><span class="comment">// result1: Angle = Angle(4.495959481852481)
</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(0.19123551744908363)</span></code></pre>
</span><span class="comment">// result2: Angle = Angle(0.4608409322989578)</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(5.42995863213066)
</span><span class="comment">// result1: Angle = Angle(1.7663768861311724)
</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(5.42995863213066)</span></code></pre>
</span><span class="comment">// result2: Angle = Angle(1.7663768861311724)</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 @@ -188,7 +188,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.8153411613693412</span></code></pre>
</span><span class="comment">// res0: Double = 0.4268439387353803</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 @@ -226,9 +226,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(1.136233097161686)
</span><span class="comment">// res1: Angle = Angle(5.386389735333367)
</span><span class="identifier">randomAngle</span><span>.</span><span class="identifier">run</span><span>
</span><span class="comment">// res2: Angle = Angle(5.26138151219521)</span></code></pre>
</span><span class="comment">// res2: Angle = Angle(5.684363869337448)</span></code></pre>

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

Expand Down
8 changes: 4 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14557,10 +14557,6 @@ $c_Lpolygons_Polygons$.prototype.polygonPointsExercise__T__V = (function(id) {
var this$11 = $m_Ldoodle_image_syntax_package$all$();
new $c_Ldoodle_image_syntax_AbstractImageSyntax$ImageOps(this$11, image).drawWithFrame__O__Ldoodle_effect_Renderer__Lcats_effect_unsafe_IORuntime__V($n($m_Ldoodle_svg_package$().Ldoodle_svg_package$__f_Frame).apply__T__Ldoodle_svg_effect_Frame(id), $m_Ldoodle_svg_package$().Ldoodle_svg_package$__f_svgRenderer, $m_Lcats_effect_unsafe_IORuntime$().global__Lcats_effect_unsafe_IORuntime())
});
$c_Lpolygons_Polygons$.prototype.points = (function(arg) {
var prep0 = $as_T(arg);
this.points__T__V(prep0)
});
$c_Lpolygons_Polygons$.prototype.polygonPointsExercise = (function(arg) {
var prep0 = $as_T(arg);
this.polygonPointsExercise__T__V(prep0)
Expand All @@ -14569,6 +14565,10 @@ $c_Lpolygons_Polygons$.prototype.vertices = (function(arg) {
var prep0 = $as_T(arg);
this.vertices__T__V(prep0)
});
$c_Lpolygons_Polygons$.prototype.points = (function(arg) {
var prep0 = $as_T(arg);
this.points__T__V(prep0)
});
var $d_Lpolygons_Polygons$ = new $TypeData().initClass({
Lpolygons_Polygons$: 0
}, false, "polygons.Polygons$", {
Expand Down
2 changes: 1 addition & 1 deletion main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion part-two-introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ <h1 id="part-two-introduction" class="title">Part Two: Introduction</h1>

<h2 id="setup" class="section">Setup</h2>
<p>To work through this part of the book use a new project.
Download from Github.</p>
Download the <a href="https://github.com/creativescala/creative-scala-data-template">creative-scala-data-template</a> from Github.</p>
<div class="flex flex-row justify-between">
<a class="pageNavigation" href="part-one-conclusions.html">←Part One: Conclusions</a> <a class="pageNavigation" href="part-two/loading-data/">Loading Data→</a>
</div>
Expand Down

0 comments on commit 52c9a77

Please sign in to comment.