Skip to content

Commit f4ed865

Browse files
Replaced homophobic example text (learnyouahaskell#21)
Thank you for your contribution! 🙂 We'd be happy to implement any of your other suggestions, extensions or redactions to the work.
1 parent 50816b1 commit f4ed865

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/higher-order-functions.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ <h1 style="margin-left:-3px">Higher order functions</h1>
198198
[[1,2,3],[3,4,5],[2,2]]
199199
ghci&gt; filter (`elem` ['a'..'z']) "u LaUgH aT mE BeCaUsE I aM diFfeRent"
200200
"uagameasadifeent"
201-
ghci&gt; filter (`elem` ['A'..'Z']) "i lauGh At You BecAuse u r aLL the Same"
202-
"GAYBALLS"
201+
ghci&gt; filter (`elem` ['A'..'Z']) "i Laugh At you Because u R All The Same"
202+
"LABRATS"
203203
</pre>
204204
<p>All of this could also be achived with list comprehensions by the use of predicates. There's no set rule for when to use <span class="fixed">map</span> and <span class="fixed">filter</span> versus using list comprehension, you just have to decide what's more readable depending on the code and the context. The <span class="fixed">filter</span> equivalent of applying several predicates in a list comprehension is either filtering something several times or joining the predicates with the logical <span class="fixed">&amp;&amp;</span> function. </p>
205205
<p>Remember our quicksort function from the <a href="recursion.html">previous chapter</a>? We used list comprehensions to filter out the list elements that are smaller than (or equal to) and larger than the pivot. We can achieve the same functionality in a more readable way by using <span class="fixed">filter</span>:</p>

0 commit comments

Comments
 (0)