Skip to content

Commit

Permalink
deploy: e7307c1
Browse files Browse the repository at this point in the history
  • Loading branch information
noelwelsh committed Nov 29, 2023
1 parent d281340 commit 85c8559
Show file tree
Hide file tree
Showing 8 changed files with 36 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 @@ -177,12 +177,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$15797/0x0000000103fbc840@4494e5a2,
// onMouseMoveHandler = doodle.reactor.Reactor$$$Lambda$15798/0x0000000103fbd840@329037f6,
// onTickHandler = doodle.reactor.Reactor$$$Lambda$15802/0x0000000103fc8840@1f416d11,
// onMouseClickHandler = doodle.reactor.Reactor$$$Lambda$14329/0x0000000103bb1840@54e4d7ca,
// onMouseMoveHandler = doodle.reactor.Reactor$$$Lambda$14330/0x0000000103bb2040@6044b316,
// onTickHandler = doodle.reactor.Reactor$$$Lambda$14334/0x0000000103bb7040@6bdbb684,
// tickRate = 100 milliseconds,
// renderHandler = repl.MdocSession$MdocApp$$Lambda$15804/0x0000000103fca840@22c8374b,
// stopHandler = doodle.reactor.Reactor$$$Lambda$15803/0x0000000103fc9840@12ea6200
// renderHandler = repl.MdocSession$MdocApp$$Lambda$14336/0x0000000103bb5840@3b146b83,
// stopHandler = doodle.reactor.Reactor$$$Lambda$14335/0x0000000103bb6040@397f2d9d
// )</span></code></pre>
<div class="flex flex-row justify-between">
<a class="pageNavigation" href="index.html">←Animation and Fireworks</a> <a class="pageNavigation" href="../adt/">Algebraic Data Types To Call Our Own→</a>
Expand Down
6 changes: 3 additions & 3 deletions flowers/functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -355,17 +355,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$16125/0x00000001040d4840@3def2f88</span></code></pre>
</span><span class="comment">// res10: Function1[Int, Int] = repl.MdocSession$MdocApp0$$Lambda$14657/0x0000000103cd8840@243d49fd</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$16126/0x00000001040d5840@5418ece7</span></code></pre>
</span><span class="comment">// res11: Function1[Color, HSLA] = repl.MdocSession$MdocApp0$$Lambda$14658/0x0000000103cd9040@64b8464c</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$16127/0x00000001040d6040@78d79b8</span></code></pre>
</span><span class="comment">// res12: Function1[Image, Image] = repl.MdocSession$MdocApp0$$Lambda$14659/0x0000000103cda040@2b499d1e</span></code></pre>
</div>
</div>
<div class="exercise">
Expand Down
5 changes: 4 additions & 1 deletion foreword-2.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ <h1 id="foreword-to-the-second-edition" class="title">Foreword to the Second Edi
<p>One more thing: the name may change as well! I&#39;m not sure Creative Scala fits the book I&#39;m aiming for.</p>

<h2 id="acknowledgements" class="section">Acknowledgements</h2>
<p>The members of ScalaBridge London </p>
<p>The members of ScalaBridge London, with particular mention to the following for reporting bugs and suggesting improvements:</p>
<ul>
<li>Jess Gordon</li>
</ul>
<div class="flex flex-row justify-between">
<a class="pageNavigation" href="foreword-1.html">←Foreword to the First Edition</a> <a class="pageNavigation" href="setup/">Getting Started→</a>
</div>
Expand Down
16 changes: 8 additions & 8 deletions generative/flatmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,15 @@ <h4 id="randomness-and-randomness" class="section">Randomness and Randomness {-}
// c = FlatMapped(
// c = FlatMapped(
// c = Suspend(a = RDouble),
// f = cats.free.Free$$Lambda$16188/0x00000001040fc040@db49686
// f = cats.free.Free$$Lambda$14720/0x0000000103cee040@39ab6f01
// ),
// f = cats.free.Free$$Lambda$16188/0x00000001040fc040@36239c6d
// f = cats.free.Free$$Lambda$14720/0x0000000103cee040@62865eb0
// ),
// f = cats.free.Free$$Lambda$16188/0x00000001040fc040@4101806c
// f = cats.free.Free$$Lambda$14720/0x0000000103cee040@28068328
// ),
// f = repl.MdocSession$MdocApp5$$Lambda$16205/0x0000000104105040@2ef9cf40
// f = repl.MdocSession$MdocApp5$$Lambda$14737/0x0000000103cfd040@657c6310
// ),
// f = repl.MdocSession$MdocApp5$$Lambda$16208/0x0000000104102840@7d07cbf
// f = repl.MdocSession$MdocApp5$$Lambda$14740/0x0000000103d09040@7cddbd9
// )</span></code></pre>
<p>which makes it clearer that we&#39;re generating three different circles.
&lt;/div&gt;</p>
Expand All @@ -393,17 +393,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$16188/0x00000001040fc040@2dba58dc
// f = cats.free.Free$$Lambda$14720/0x0000000103cee040@57ee764e
// )
</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$16188/0x00000001040fc040@2dba58dc
// f = cats.free.Free$$Lambda$14720/0x0000000103cee040@57ee764e
// ),
// f = cats.free.Free$$Lambda$16188/0x00000001040fc040@6075bfe7
// f = cats.free.Free$$Lambda$14720/0x0000000103cee040@4beda058
// )
</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 @@ -200,29 +200,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.3763503668137944
</span><span class="comment">// res0: Double = 0.15820054643198922
</span><span class="identifier">math</span><span>.</span><span class="identifier">random</span><span>
</span><span class="comment">// res1: Double = 0.9996983033211917</span></code></pre>
</span><span class="comment">// res1: Double = 0.6540477237078933</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(3.5257863172154527)
</span><span class="comment">// res2: Angle = Angle(1.5234966553904867)
</span><span class="identifier">randomAngle</span><span>
</span><span class="comment">// res3: Angle = Angle(2.2293765218935695)</span></code></pre>
</span><span class="comment">// res3: Angle = Angle(2.0441351164399384)</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(1.2845734304109409)
</span><span class="comment">// result1: Angle = Angle(2.5716594542965683)
</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.37820568068132854)</span></code></pre>
</span><span class="comment">// result2: Angle = Angle(3.3051764809816437)</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(4.179152441677217)
</span><span class="comment">// result1: Angle = Angle(1.7680748308072984)
</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(4.179152441677217)</span></code></pre>
</span><span class="comment">// result2: Angle = Angle(1.7680748308072984)</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 @@ -185,7 +185,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.4466396033751239</span></code></pre>
</span><span class="comment">// res0: Double = 0.4613818598813554</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 @@ -223,9 +223,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(3.585828190507099)
</span><span class="comment">// res1: Angle = Angle(2.3869408809794046)
</span><span class="identifier">randomAngle</span><span>.</span><span class="identifier">run</span><span>
</span><span class="comment">// res2: Angle = Angle(4.046321669369071)</span></code></pre>
</span><span class="comment">// res2: Angle = Angle(1.2613370409296354)</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 @@ -6234,14 +6234,14 @@ $c_Lflowers_FlowersFun$.prototype.growingCirclesExample__T__V = (function(id) {
var image$2 = this.fold__I__F2__Ldoodle_image_Image(5, growingCircles);
new $c_Ldoodle_image_syntax_AbstractImageSyntax$ImageOps(this$14, image$2).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_Lflowers_FlowersFun$.prototype.gradientBoxesExample = (function(arg) {
var prep0 = $as_T(arg);
this.gradientBoxesExample__T__V(prep0)
});
$c_Lflowers_FlowersFun$.prototype.growingCirclesExample = (function(arg) {
var prep0 = $as_T(arg);
this.growingCirclesExample__T__V(prep0)
});
$c_Lflowers_FlowersFun$.prototype.gradientBoxesExample = (function(arg) {
var prep0 = $as_T(arg);
this.gradientBoxesExample__T__V(prep0)
});
var $d_Lflowers_FlowersFun$ = new $TypeData().initClass({
Lflowers_FlowersFun$: 0
}, false, "flowers.FlowersFun$", {
Expand Down
2 changes: 1 addition & 1 deletion main.js.map

Large diffs are not rendered by default.

0 comments on commit 85c8559

Please sign in to comment.