diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-02-08 18:36:10 -0700 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-02-08 18:36:10 -0700 |
commit | 5b8b3abcba8746502014266583907421b71a330b (patch) | |
tree | fc3d8a2159a17c8af1d432d93307ff01474fb053 /script.md | |
parent | c18b81b2f26123481558cb3fffc794c2c13f74ad (diff) | |
download | compiling-the-lambda-calculus-5b8b3abcba8746502014266583907421b71a330b.tar.gz compiling-the-lambda-calculus-5b8b3abcba8746502014266583907421b71a330b.zip |
add hungry partner function
Diffstat (limited to 'script.md')
-rw-r--r-- | script.md | 33 |
1 files changed, 12 insertions, 21 deletions
@@ -41,38 +41,29 @@ Yes, hmmm... so, do you really think this is so? > yes ``` -well that's not super helpful +well that's not super helpful, looks like the "AI repeating itself" notion is nothing modern. -It looks like we have a black box here that came out of nowhere. What does it do? +On our journey to get a valentine, looks like we have stumbled across a black box. What does it do? Well... we could start shoving random numbers in it and see what happens. -When we feed it a one and put it at this arrow, it returns one. When we feed it a two, it returns one. A three, two. A four, three. And so forth. -No matter how many times we put a number in it gives me the same answer; we're all in love with it already. +hmm... [-1, 2]? okay, 1. [3, 4]? okay, 7. what if we try [-1, 2] again, see if it meets our criteria to our valentine. amazing! -So we're ready to start getting to know this so called "function". Where could our curiosity take us? +No matter how many times we put two numbers in it gives me the same answer; we're in love with it already! -Let's look at what's behind this black box. +So we're ready to start getting to know this black box. Let's look at what's behind this black box. -Ah. A simple fibonacci function. +Now where could our curiosity take us? -```python -def fib(n): - if (n <= 2): - return 1 - return fib(n - 1) + fib(n - 2) -``` +Ah. A simple add function. -We're in love with its predictability, the assurance that no matter what we give as input, the function behaves in a consistent manner. +We're in love with its predictability, the assurance that no matter what we give as input or how many times it's given, the function behaves in a consistent manner. -But let's imagine, for a moment, a different kind of relationship. One where actions outside the relationship influence your partner's responses. +But let's imagine, for a moment, a different kind of relationship. One where actions outside the relationship influences responses. -Imagine asking your partner about what food they want to eat. But instead of a straightforward answer based on your question alone and some state (i.e. hunger levels, craving ratios, etc), the function's response is influenced by other factors; the day of the week, and the state of the day or week prior. +Imagine asking your partner about what food they want to eat. But instead of a straightforward answer based on your question alone and some state (i.e. hunger levels, craving ratios, etc), the function's response is influenced by other factors; the day of the week, and the state of the day or week prior. We can simulate this: (go through some ratios and outputs). -```python -def random_number(): - return 4 # picked randomly -``` +Let's see what causes this in this black box we don't love; don't pay attention to the implementation (there's some stuff we haven't talked about yet), but check out this line (MATH.RANDOM). This is a side effect; an unpredictible effect on the output. -This unpredictability is what side effects introduce into our programming relationships. Where output is not just determined by its input but also by the state of the outside world, or the system at the time of execution. Suddenly, the predictability we cherished is compromised. (we'll talk about this more later) +Side effects introduce unpredictability into our programming relationships. Where output is not just determined by its input but also by the state of the outside world, or the system at the time of execution. Suddenly, the predictability we cherished is compromised. (we'll go much more in depth about this more later) So let's take our love of this function and begin studying it. |