style changes
This commit is contained in:
parent
fb5a8c3984
commit
1a2629f9e0
|
@ -55,7 +55,7 @@ f⁻¹ . f = id
|
||||||
|
|
||||||
we construct
|
we construct
|
||||||
|
|
||||||
```
|
```hs
|
||||||
f :: (a, Either b c) -> Either (a, b) (a, c)
|
f :: (a, Either b c) -> Either (a, b) (a, c)
|
||||||
f (a, Left b) = Left (a, b)
|
f (a, Left b) = Left (a, b)
|
||||||
f (a, Right c) = Right (a, c)
|
f (a, Right c) = Right (a, c)
|
||||||
|
|
|
@ -5,7 +5,9 @@ layout: default
|
||||||
<header>
|
<header>
|
||||||
<nav><ul>
|
<nav><ul>
|
||||||
<li class="sitetitle">
|
<li class="sitetitle">
|
||||||
|
<div class="titlecontainer">
|
||||||
<a class="bigger" href="/">rachel.cafe</a>
|
<a class="bigger" href="/">rachel.cafe</a>
|
||||||
|
</div
|
||||||
</li>
|
</li>
|
||||||
</nav></ul>
|
</nav></ul>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
|
@ -35,7 +35,7 @@ With this in mind, it might come as a surprise that there is a closed, non-recur
|
||||||
# Programmatically calculating the $$n$$-th Fibonacci number
|
# Programmatically calculating the $$n$$-th Fibonacci number
|
||||||
|
|
||||||
A naive way of calculating the $$n$$-th Fibonacci number is to use the definition above. Check if $$n = 0$$, if $$n = 1$$, and otherwise calculating $$f_{n-2}$$ and $$f_{n-1}$$. This corresponds to the following Haskell code:
|
A naive way of calculating the $$n$$-th Fibonacci number is to use the definition above. Check if $$n = 0$$, if $$n = 1$$, and otherwise calculating $$f_{n-2}$$ and $$f_{n-1}$$. This corresponds to the following Haskell code:
|
||||||
```
|
```hs
|
||||||
fib :: Integer -> Integer
|
fib :: Integer -> Integer
|
||||||
fib 0 = 0
|
fib 0 = 0
|
||||||
fib 1 = 1
|
fib 1 = 1
|
||||||
|
@ -45,7 +45,7 @@ fib n = fib (n-2) + fib (n-1)
|
||||||
However, there is an issue with this method, many Fibonacci numbers will be calculated numerous times, as for each Fibonacci number evaluated we split into two paths, evaluating the previous and twice previous Fibonacci number. The reader which prefers visuals might appreciate Figure 1.5 from the SICP chapter.
|
However, there is an issue with this method, many Fibonacci numbers will be calculated numerous times, as for each Fibonacci number evaluated we split into two paths, evaluating the previous and twice previous Fibonacci number. The reader which prefers visuals might appreciate Figure 1.5 from the SICP chapter.
|
||||||
|
|
||||||
How might we fix this then? A human calculating the $$n$$-th Fibonacci number might construct a list of Fibonacci numbers, calculating each Fibonacci number only once. While it is possible to do this on the computer it is superfluous to carry around all previous numbers, as we only need the previous two to calculate the next one. We might think of this as a 2-slot window, moving along the Fibonacci numbers, taking $$n$$ steps to arrive at $$f_n$$. In code we could represent this as follows:
|
How might we fix this then? A human calculating the $$n$$-th Fibonacci number might construct a list of Fibonacci numbers, calculating each Fibonacci number only once. While it is possible to do this on the computer it is superfluous to carry around all previous numbers, as we only need the previous two to calculate the next one. We might think of this as a 2-slot window, moving along the Fibonacci numbers, taking $$n$$ steps to arrive at $$f_n$$. In code we could represent this as follows:
|
||||||
```
|
```hs
|
||||||
-- steps -> f n-2 -> f n-1 -> f n
|
-- steps -> f n-2 -> f n-1 -> f n
|
||||||
window :: Integer -> Integer -> Integer -> Integer
|
window :: Integer -> Integer -> Integer -> Integer
|
||||||
window 0 a b = a
|
window 0 a b = a
|
||||||
|
|
|
@ -8,13 +8,8 @@
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: "SAX2";
|
font-family: "SAX2";
|
||||||
background: #1d1f21;
|
background: #FCEFDB;
|
||||||
|
color: black;
|
||||||
background-image: url(/assets/img/bg.png);
|
|
||||||
background-repeat: repeat;
|
|
||||||
background-position: center;
|
|
||||||
|
|
||||||
color: #c5c8c6;
|
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
@ -76,8 +71,8 @@ a:hover {
|
||||||
color: #70c0b1;
|
color: #70c0b1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sitetitle a, {
|
.titlecontainer a {
|
||||||
color: #b55690;
|
font-size: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sitetitle {
|
.sitetitle {
|
||||||
|
@ -87,6 +82,21 @@ a:hover {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.titlecontainer {
|
||||||
|
background-image: url(/assets/img/bg.png);
|
||||||
|
background-repeat: repeat;
|
||||||
|
background-position: center;
|
||||||
|
background-size: 10em;
|
||||||
|
padding-top: 4em;
|
||||||
|
padding-bottom: 4em;
|
||||||
|
margin-top: 2em;
|
||||||
|
margin-bottom: 2em;
|
||||||
|
width: 80%;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 5px;
|
||||||
|
border-color: #d54e53;
|
||||||
|
}
|
||||||
|
|
||||||
.right {
|
.right {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
float: right;
|
float: right;
|
||||||
|
@ -108,31 +118,6 @@ a:hover {
|
||||||
max-width: 200%;
|
max-width: 200%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (max-width : 850px) {
|
|
||||||
|
|
||||||
.centercol {
|
|
||||||
box-sizing: border-box !important;
|
|
||||||
width: 100vw !important;
|
|
||||||
padding: 10px !important;
|
|
||||||
backdrop-filter: blur(4px) !important;
|
|
||||||
-webkit-backdrop-filter: blur(4px) !important;
|
|
||||||
box-shadow: none !important;
|
|
||||||
-webkit-box-shadow: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.aba {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: top;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rimg {
|
|
||||||
margin: 1em 0 0 0;
|
|
||||||
width: 70%;
|
|
||||||
max-width: 70%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.posts {
|
.posts {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
@ -155,7 +140,6 @@ nav ul {
|
||||||
|
|
||||||
nav ul li {
|
nav ul li {
|
||||||
display: inline;
|
display: inline;
|
||||||
margin-right: 1em;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,11 +160,11 @@ table {
|
||||||
width: 60em;
|
width: 60em;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
max-width: 94vw;
|
max-width: 94vw;
|
||||||
padding: 4em;
|
padding-left: 4em;
|
||||||
backdrop-filter: blur(7px);
|
padding-right: 4em;
|
||||||
-webkit-backdrop-filter: blur(7px);
|
border-style: solid;
|
||||||
box-shadow: 0 0 0 5px #d54e53;
|
border-width: 0 5px;
|
||||||
-webkit-box-shadow: 0 0 0 5px #d54e53;
|
border-color: #d54e53;
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
|
@ -192,7 +176,6 @@ table {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
filter: invert(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.cdfig {
|
.cdfig {
|
||||||
|
@ -274,3 +257,32 @@ table {
|
||||||
.highlight .vg { color: #ebdbb2; background-color: #282828 } /* Name.Variable.Global */
|
.highlight .vg { color: #ebdbb2; background-color: #282828 } /* Name.Variable.Global */
|
||||||
.highlight .vi { color: #ebdbb2; background-color: #282828 } /* Name.Variable.Instance */
|
.highlight .vi { color: #ebdbb2; background-color: #282828 } /* Name.Variable.Instance */
|
||||||
.highlight .il { color: #d3869b; background-color: #282828 } /* Literal.Number.Integer.Long */
|
.highlight .il { color: #d3869b; background-color: #282828 } /* Literal.Number.Integer.Long */
|
||||||
|
|
||||||
|
@media only screen and (max-width : 850px) {
|
||||||
|
|
||||||
|
.centercol {
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100vw;
|
||||||
|
max-width: 100vw;
|
||||||
|
padding-left: 2em;
|
||||||
|
padding-right: 2em;
|
||||||
|
border-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.titlecontainer {
|
||||||
|
width: 100%
|
||||||
|
}
|
||||||
|
|
||||||
|
.aba {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rimg {
|
||||||
|
margin: 1em 0 0 0;
|
||||||
|
width: 70%;
|
||||||
|
max-width: 70%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user