SlideShare une entreprise Scribd logo
1  sur  51
Télécharger pour lire hors ligne
,

.

.
- https://open.kakao.com/o/
gMvUe8Kb



- https://github.com/wanbok/
LetSwiftWorkShop
1. 

2. / 

1. filter, reduce, map, flatMap 

2. iOS Swift 

3. Git, Github 

3.
(Cognitive Complexity) 

SonarQube
.

1. .

2. (
) 1 .

3. .
4 .

A. (Nesting) - 

B. (Structural) - + 

C. Fundamental -


D. Hybrid -
(Cyclomatic Complexity) 



• Callback hell

• If else 

SonarQube ,
0. Tutorial
• 

• 

• 

• 

• (Side effect) 

•
• (Pure function)

• input output, 

• (Anonymous function)

• Swift Closure, Obj-c Block

• (Higher-order function)

• forEach, filter, first/last(where:), reduce

• map, flatMap, compactMap
For-in loop 

• loop
["This", "is", “Sparta!"]
.forEach { print($0) }
// This
// is
// Sparta!
(Element)
["This", "is", “Sparta!"]
.filter { $0.contains("is") }
.forEach { print($0) }
// This
// is
["This", "is", "Sparta!"]
.first(where: { $0.contains("is") })?
.forEach { print($0) }
// This
["This", "is", "Sparta!"]
.reduce("", { (sentence, word) -> String in
sentence + " " + word
})
// "This is Sparta!"
, Type
(Transform)
["This", "is", "Sparta!"]
.map { (text) -> Int in return text.count }
// .map { $0.count }
// [4, 2, 7]
Dictionary (key, value) tuple
.

.

let result: [String] = dict
.map { (each: (key: String, value: Int)) -> String in
"(each.key): (each.value)"
}
map 

let priceString = "100 "
let parsedNumber: Int? = Int(priceString)
parsedNumber.map { “($0 / 10) ” }
// Optional(“10 ")
Context
(Container)
Collection, Optional, Result , value
Value
(Content)
, context
Transform
(Function)
value value
(Value) Context , map function
* .
context 

• map + flatten
[[1, 2, 3], [4, 5, 6], []]
.flatMap { (numberList) -> [Int] in
return numberList.map { $0 * $0 }
}
// [1, 4, 9, 16, 25, 36]
context 

• (Transfrom)
let number: Int? = 10
number
.flatMap { (number) -> String? in
guard number % 2 == 0 else { return nil }
return “(number) ”
}
// Optional.some Optional.none
(Value) Context , flatMap
function
* .
Collection nil
["This", nil, "is", "Sparta!", nil]
.compactMap { $0 }
// ["This", "is", "Sparta!"]
flatMap 

• context 

• [String?].flatMap { element -> String? }

• flatMap { element -> [String?] }
1.
,
• .

• .

• .

• .

•
• .

• .

• .

• .

• (Nested) 

• Non-local
class Model {
init(dictionary: [String: Any]) {
…
}
}
let dictionary: [String: Any]? = …
if let dictionary = dictionary {
let model = Model(dictionary: dictionary)
}
class Model {
init(dictionary: [String: Any]) {
…
}
}
let dictionary: [String: Any]? = …
dictionary.map { Model(dictionary: $0) }
class Model {
init(dictionary: [String: Any]) {
…
}
}
let dictionary: [String: Any]? = …
dictionary.map({ Model(dictionary: $0) })
class Model {
init(dictionary: [String: Any]) {
…
}
}
let dictionary: [String: Any]? = …
dictionary.map(Model.init)
Observable.just(())
.observeOn(MainScheduler.instance)
.flatMap(rx.closeAnimation)
.bind(to: rx.removeFromSuperview)
.disposed(by: disposeBag)
var contraints: ((ConstraintMaker) -> Void) {
switch self {
case .top:
return {
$0.width.equalTo(size.width)
$0.height.equalTo(size.height).priority(.high)
$0.height.lessThanOrEqualTo(self.maxHeight)
$0.top.left.right.equalToSuperview()
}
case .middle:
return {
$0.height.equalTo(size.height).priority(.high)
$0.height.lessThanOrEqualTo(maxHeight)
$0.top.equalToSuperview().inset(topOffset)
$0.left.right.equalToSuperview().inset(margins)
}
}
}
…
view.snp.makeConstraints(type.contraints)
class ViewController: UIViewController {
struct Dependency {
let pushDetailView: (ViewController) -> Void
let presentLoginView: (ViewController) -> Void
}
let dependency: Dependency
init(dependency: Dependency) {
self.dependency = dependency
}
func tapDetailViewButton() {
self.dependency.pushDetailView(self)
}
}
let dependency: ViewController.Dependency = .init(
pushDetailView: { (viewController) in
viewController
.navigationController?
.pushViewController(viewController, animated: true)
},
presentLoginView: { (viewController) in … }
)
let viewController = ViewController(dependency: dependency)
Functor Monad
Container ( Context / Wrapper)

• Array, Dictionary, Result, Optional 

Functor map

Monad flatMap
2. , Functor, Monad
• Cognitive Complexity

• https://www.sonarsource.com/resources/white-papers/cognitive-complexity.html

• 

• https://ko.wikipedia.org/wiki/
%ED%95%A8%EC%88%98%ED%98%95_%ED%94%84%EB%A1%9C%EA%B7%B8
%EB%9E%98%EB%B0%8D

• Swift Functional Programming by (Naver)

• 

• https://ko.wikipedia.org/wiki/%EC%9D%BC%EA%B8%89_%EA%B0%9D%EC%B2%B4

• Functors are containers

• https://bartoszmilewski.com/2014/01/14/functors-are-containers/
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵

Contenu connexe

Tendances

Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101
Ankur Gupta
 
JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6
Solution4Future
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)
jeffz
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 

Tendances (20)

ECMAScript 6
ECMAScript 6ECMAScript 6
ECMAScript 6
 
Proxies are Awesome!
Proxies are Awesome!Proxies are Awesome!
Proxies are Awesome!
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
 
Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101
 
Mastering Kotlin Standard Library
Mastering Kotlin Standard LibraryMastering Kotlin Standard Library
Mastering Kotlin Standard Library
 
ECMA5 and ES6 Promises
ECMA5 and ES6 PromisesECMA5 and ES6 Promises
ECMA5 and ES6 Promises
 
JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6
 
Programmation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScriptProgrammation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScript
 
EcmaScript 6
EcmaScript 6 EcmaScript 6
EcmaScript 6
 
Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015
 
响应式编程及框架
响应式编程及框架响应式编程及框架
响应式编程及框架
 
RxJS 5 in Depth
RxJS 5 in DepthRxJS 5 in Depth
RxJS 5 in Depth
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6
 
JavaScript ES6
JavaScript ES6JavaScript ES6
JavaScript ES6
 
Advanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScriptAdvanced Object-Oriented JavaScript
Advanced Object-Oriented JavaScript
 
Swift rocks! #1
Swift rocks! #1Swift rocks! #1
Swift rocks! #1
 
Swift Rocks #2: Going functional
Swift Rocks #2: Going functionalSwift Rocks #2: Going functional
Swift Rocks #2: Going functional
 
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache Hadoop
 

Similaire à [Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵

Lua London Meetup 2013
Lua London Meetup 2013Lua London Meetup 2013
Lua London Meetup 2013
Cloudflare
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
Charles Nutter
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 

Similaire à [Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵 (20)

Golang勉強会
Golang勉強会Golang勉強会
Golang勉強会
 
Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010
 
NetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf EditionNetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf Edition
 
Lua London Meetup 2013
Lua London Meetup 2013Lua London Meetup 2013
Lua London Meetup 2013
 
Lua: the world's most infuriating language
Lua: the world's most infuriating languageLua: the world's most infuriating language
Lua: the world's most infuriating language
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
Real world cats
Real world catsReal world cats
Real world cats
 
A Few of My Favorite (Python) Things
A Few of My Favorite (Python) ThingsA Few of My Favorite (Python) Things
A Few of My Favorite (Python) Things
 
Kotlin For Android - Functions (part 3 of 7)
Kotlin For Android - Functions (part 3 of 7)Kotlin For Android - Functions (part 3 of 7)
Kotlin For Android - Functions (part 3 of 7)
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programming
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
 
Groovy
GroovyGroovy
Groovy
 
Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-C
 
Command Liner with Scala
Command Liner with ScalaCommand Liner with Scala
Command Liner with Scala
 
Tuga IT 2018 Summer Edition - The Future of C#
Tuga IT 2018 Summer Edition - The Future of C#Tuga IT 2018 Summer Edition - The Future of C#
Tuga IT 2018 Summer Edition - The Future of C#
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?
 
Introduction to Go
Introduction to GoIntroduction to Go
Introduction to Go
 
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Introductionto fp with groovy
Introductionto fp with groovyIntroductionto fp with groovy
Introductionto fp with groovy
 

Plus de Wanbok Choi

06 멀티뷰 애플리케이션
06 멀티뷰 애플리케이션06 멀티뷰 애플리케이션
06 멀티뷰 애플리케이션
Wanbok Choi
 
04 안드로이드 응용프로그램의 구조
04 안드로이드 응용프로그램의 구조04 안드로이드 응용프로그램의 구조
04 안드로이드 응용프로그램의 구조
Wanbok Choi
 

Plus de Wanbok Choi (9)

WWDC 2019 Cheatsheet
WWDC 2019 CheatsheetWWDC 2019 Cheatsheet
WWDC 2019 Cheatsheet
 
iOS 개발자의 Flutter 체험기
iOS 개발자의 Flutter 체험기iOS 개발자의 Flutter 체험기
iOS 개발자의 Flutter 체험기
 
[이모콘 2018 S/S] Swift로 코인 트레이딩 봇 만들기
[이모콘 2018 S/S] Swift로 코인 트레이딩 봇 만들기[이모콘 2018 S/S] Swift로 코인 트레이딩 봇 만들기
[이모콘 2018 S/S] Swift로 코인 트레이딩 봇 만들기
 
RxSwift 활용하기 - Let'Swift 2017
RxSwift 활용하기 - Let'Swift 2017RxSwift 활용하기 - Let'Swift 2017
RxSwift 활용하기 - Let'Swift 2017
 
try! Swift Tokyo 2017 후기
try! Swift Tokyo 2017 후기try! Swift Tokyo 2017 후기
try! Swift Tokyo 2017 후기
 
기획, 디자인 변경에 강한 카드뷰 만들기 - iOS Tech Talk 2017
기획, 디자인 변경에 강한 카드뷰 만들기 - iOS Tech Talk 2017기획, 디자인 변경에 강한 카드뷰 만들기 - iOS Tech Talk 2017
기획, 디자인 변경에 강한 카드뷰 만들기 - iOS Tech Talk 2017
 
LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기LetSwift RxSwift 시작하기
LetSwift RxSwift 시작하기
 
06 멀티뷰 애플리케이션
06 멀티뷰 애플리케이션06 멀티뷰 애플리케이션
06 멀티뷰 애플리케이션
 
04 안드로이드 응용프로그램의 구조
04 안드로이드 응용프로그램의 구조04 안드로이드 응용프로그램의 구조
04 안드로이드 응용프로그램의 구조
 

Dernier

DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
chumtiyababu
 

Dernier (20)

Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 

[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵