Skip to content

Commit fbf2ed4

Browse files
author
Bob Lee
committed
Finished Functional programming prep
1 parent 372ca2c commit fbf2ed4

File tree

8 files changed

+13
-11
lines changed

8 files changed

+13
-11
lines changed

course/generic-protocol/protocol-pitfalls.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ let cell: Listable = arc4random() * 2 == 0 ? FolderCell() : ListCell()
8585
`FileType` could be `Folder` or `Cell`. It is only known when you execute the `arc4Random()` method. By the time it is called, it is already compiled
8686

8787
### Source Code
88-
[6004_protocol_pitfalls](https://www.dropbox.com/sh/taxydi2cxionzxp/AAD7aKreX1i1wDwJKL1Q-yVEa?dl=0)
88+
[6004_protocol_pitfalls](https://www.dropbox.com/sh/b5wxh5lhhmqdphr/AACGBi7I9IO7jswwBgyk7fp2a?dl=0)
8989

9090
## Conclusion
9191
This is frustrating. In the following lesson, you will learn how to use the brain to circumvent the problem.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
//: ## Map
33

4-
extension Array { // # ,$ ,% ,&
4+
extension Array {
55
func myMap<T>(_ transform: (Element) -> T) -> [T] {
66
var result: [T] = []
77
for x in self {
@@ -18,5 +18,7 @@ Array(1...10).myMap { (Number) -> Int in
1818

1919
let suits = ["", "", "", ""]
2020
let ranks = ["J","Q","K","A"]
21-
let result = suits.flatMap { suit in ranks.map { rank in (suit, rank) }
21+
let result = suits.flatMap { suit in ranks.map {
22+
rank in (suit, rank)
23+
}
2224
}
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
### Functional Programming
55
### Reduce
66

7-
**Problem:** Reduce
7+
**Problem:** Convert big numbers to one or more
88
*/
99

1010

Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*:
22
## Learn Swift with Bob
33
### Functional Programming
4-
### Intro to Functional Paradigm
4+
### Flatmap
55

6-
**Problem:** What's functional?
6+
**Problem:** Make it nice and plain
77
*/
88

99

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<playground version='6.0' target-platform='ios' display-mode='raw'>
33
<pages>
4-
<page name='intro_functional'/>
5-
<page name='filter'/>
6-
<page name='flatmap'/>
7-
<page name='map'/>
8-
<page name='reduce'/>
4+
<page name='0001_intro_functional'/>
5+
<page name='0002_filter'/>
6+
<page name='0003_map'/>
7+
<page name='0004_reduce'/>
8+
<page name='0005_flatmap'/>
99
</pages>
1010
</playground>

0 commit comments

Comments
 (0)