mirror of
https://github.com/Brandon-Rozek/website.git
synced 2025-10-09 22:41:13 +00:00
Syndicated to Medium
This commit is contained in:
parent
17e7209a41
commit
bfa4e52c0b
15 changed files with 95 additions and 75 deletions
|
@ -1,10 +1,14 @@
|
|||
---
|
||||
title: "Fold Not Only Reduces"
|
||||
date: 2022-11-09T15:15:10-05:00
|
||||
date: 2022-11-09 15:15:10-05:00
|
||||
draft: false
|
||||
tags: ["Functional Programming", "Scala", "Haskell"]
|
||||
math: false
|
||||
medium_enabled: true
|
||||
medium_post_id: b419f7d25313
|
||||
tags:
|
||||
- Functional Programming
|
||||
- Scala
|
||||
- Haskell
|
||||
title: Fold Not Only Reduces
|
||||
---
|
||||
|
||||
One misconception when first learning about fold is that it takes a list of elements of a certain type (`List[T]`) and "reduces" it to a single item of type `T`.
|
||||
|
@ -60,5 +64,4 @@ Haskell Example:
|
|||
l5 c n if n > 5 then c ++ [n] else c
|
||||
foldl l5 [] [5, 7, 1, 8, 9, 3]
|
||||
-- Returns [7,8,9]
|
||||
```
|
||||
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue