Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/cftbat/functional-programming.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1>Functional Programming</h1>
<p class="Body">The core concepts you’ll learn include: what pure functions are and why they’re useful; how to work with immutable data structures and why they’re superior to their mutable cousins; how disentangling data and functions gives you more power and flexibility; and why it’s powerful to program to a small set of data abstractions. Once you shove all this knowledge into your brain matter, you’ll have an entirely new approach to problem solving!</p>
<p class="Body"><span>After going over these topics, you’ll put everything you’ve learned to use </span><span>by writing a terminal-based game inspired by an ancient, mystic mind-</span><span>training</span><span> </span><span>device found in Cracker Barrel restaurants across America: Peg Thing<a id="Anchor"></a>!</span></p>
<h2>Pure Functions: What and Why</h2>
<p class="BodyFirst">Except for <code>println</code> and <code>rand</code>, all the functions you’ve used up till now have been pure functions. What makes them pure functions, and why does it matter? A function is pure if it meets two qualifications:</p>
<p class="BodyFirst">Except for <code>println</code>, <code>rand</code> and <code>slurp</code>, all the functions you’ve used up till now have been pure functions. What makes them pure functions, and why does it matter? A function is pure if it meets two qualifications:</p>
<ul class="List-1">
<li class="BulletA">It always returns the same result if given the same arguments. This is called <em>referential transparency</em>, and you can add it to your list of $5 programming terms.</li>
<li class="BulletC"><span>It can’t cause any </span><span>side effects. That is, the function can’t make any </span><span>changes that are observable outside the function itself—for example, by </span>changing an externally accessible mutable object or writing to a file.</li>
Expand Down