SlideShare une entreprise Scribd logo
1  sur  80
Télécharger pour lire hors ligne
func ( : ) ->
(( ) -> )
func ( : ) ->
( ) ->
func add(_ value1: Int, _ value2: Int) -> Int {
return value1 + value2
}
add(2,3)
func curriedAdd(_ value1: Int) -> ( (Int) -> Int ) {
return { value2 in
return value1 + value2
}
}
func curriedAdd(_ value1: Int) -> ( (Int) -> Int ) {
return { value2 in
return value1 + value2
}
}
let add2 = curriedAdd(2)
add2(3)
func curriedAdd(_ value1: Int) -> ( (Int) -> Int ) {
return { value2 in
return value1 + value2
}
}
let add2 = curriedAdd(2)
add2(3)
curriedAdd(2)(3)
let add2 = curriedAdd(2)
add2(3)
curriedAdd(2)(3)
func curriedAdd(_ value1: Int) -> (Int) -> Int {
return { value2 in
return value1 + value2
}
}
"aaa/bbb/ccc/ddd".components(separatedBy: "/")
"aaa*bbb*ccc*ddd".components(separatedBy: "*")
func stringDevider(_ seperater: String) -> (String) -> [String] {
return { (string: String) -> [String] in
return string.components(separatedBy: seperater)
}
}
let stringDevideBySlash = stringDevider("/")
let stringDevideByAsterisk = stringDevider("*")
stringDevideBySlash("aaa/bbb/ccc/ddd")
stringDevideByAsterisk("aaa*bbb*ccc*ddd")
class SomeClass {
func someFunction() {
}
}
class SomeClass {
func someFunction() {
}
}
let someinstance = SomeClass()
someinstance.someFunction()
class SomeClass {
func someFunction() {
}
}
let someinstance = SomeClass()
someinstance.someFunction()
class SomeClass {
func someFunction() {
}
}
let someinstance = SomeClass()
someinstance.someFunction()
class SomeClass {
func someFunction() {
}
}
let someinstance = SomeClass()
someinstance.someFunction()
class SomeClass {
func someFunction() {
}
}
let someinstance = SomeClass()
someinstance.someFunction()
SomeClass.someFunction(someinstance)()
class SomeClass {
func someFunction() {
}
}
let someinstance = SomeClass()
someinstance.someFunction()
SomeClass.someFunction(someinstance)()
func regexTest(pattern: String) -> (String) -> Bool
{
let expression: NSRegularExpression? =
try? NSRegularExpression(pattern: pattern,
options: .caseInsensitive)
return { (input: String) -> Bool in
guard let expression = expression else { return false }
let inputRange = NSMakeRange(0, input.characters.count)
let matches = expression.matches(in: input,
options: [],
range: inputRange)
return matches.count > 0
}
}
func regexTest(pattern: String) -> (String) -> Bool
{
let expression: NSRegularExpression? =
try? NSRegularExpression(pattern: pattern,
options: .caseInsensitive)
return { (input: String) -> Bool in
guard let expression = expression else { return false }
let inputRange = NSMakeRange(0, input.characters.count)
let matches = expression.matches(in: input,
options: [],
range: inputRange)
return matches.count > 0
}
}
func regexTest(pattern: String) -> (String) -> Bool
regexTest(pattern: "main")("int main()")
{
let expression: NSRegularExpression? =
try? NSRegularExpression(pattern: pattern,
options: .caseInsensitive)
return { (input: String) -> Bool in
guard let expression = expression else { return false }
let inputRange = NSMakeRange(0, input.characters.count)
let matches = expression.matches(in: input,
options: [],
range: inputRange)
return matches.count > 0
}
}
func regexTest(pattern: String) -> (String) -> Bool
regexTest(pattern: "main")("int main()")
let hasMainIn = regexTest(pattern: "main")
hasMainIn("int main()")
class Regex {
var internalExpression: NSRegularExpression?
init(_ pattern: String) {
self.internalExpression =
try? NSRegularExpression(pattern: pattern, options: .caseInsensitive)
}
func test(_ input: String) -> Bool {
let inputRange = NSMakeRange(0, input.characters.count)
guard let matchesCount = self.internalExpression?
.matches(in: input, options: [], range:inputRange)
.count else { return false }
return matchesCount > 0
}
}
class Regex {
var internalExpression: NSRegularExpression?
init(_ pattern: String) {
self.internalExpression =
try? NSRegularExpression(pattern: pattern, options: .caseInsensitive)
}
func test(_ input: String) -> Bool {
let inputRange = NSMakeRange(0, input.characters.count)
guard let matchesCount = self.internalExpression?
.matches(in: input, options: [], range:inputRange)
.count else { return false }
return matchesCount > 0
}
}
let regex = Regex("main")
regex.test("int main()")
Regex("main").test("int main()")
class Regex {
var internalExpression: NSRegularExpression?
init(_ pattern: String) {
self.internalExpression =
try? NSRegularExpression(pattern: pattern, options: .caseInsensitive)
}
func test(_ input: String) -> Bool {
let inputRange = NSMakeRange(0, input.characters.count)
guard let matchesCount = self.internalExpression?
.matches(in: input, options: [], range:inputRange)
.count else { return false }
return matchesCount > 0
}
}
let regex = Regex("main")
regex.test("int main()")
Regex("main").test("int main()")
let hasMainIn = Regex("main").test
hasMainIn("int main()")
struct Friend {
var name: String
var id: Int
}
struct Friend {
var name: String
var id: Int
}
let friends = [Friend(name:" ", id: 1),
Friend(name:" ", id: 2),
Friend(name:" ", id: 3),
Friend(name:" ", id: 4),
Friend(name:" ", id: 5)]
struct Friend {
var name: String
var id: Int
}
let friends = [Friend(name:" ", id: 1),
Friend(name:" ", id: 2),
Friend(name:" ", id: 3),
Friend(name:" ", id: 4),
Friend(name:" ", id: 5)]
func inviteFriend(ID: Int) -> Void
let actionsheet = UIAlertController(title: " ", message: " ",
preferredStyle: .actionSheet)
let actionsheet = UIAlertController(title: " ", message: " ",
preferredStyle: .actionSheet)
UIAlertAction(title: String?, style: UIAlertActionStyle, handler:
((UIAlertAction) -> Void)?)
func actionHandler(friendID: Int) -> (UIAlertAction) -> () {
return { [weak self] action -> Void in
self?.inviteFriend(ID: friendID)
}
}
friends.forEach{ (friend: Friend) in
actionsheet.addAction(UIAlertAction(title: friend.name,
style: UIAlertActionStyle.default,
handler: actionHandler(friendID:
friend.id)))
}
actionsheet.addAction(UIAlertAction(title: " ", style: .cancel, handler: nil))
class ViewController: UIViewController {
@IBOutlet var yellowBox: UIView!
}
class ViewController: UIViewController {
@IBOutlet var yellowBox: UIView!
}
extension ViewController {
@IBAction func leftButtonTapped(_ sender: Any) {
UIView.animate(withDuration: 0.5, animations: {
var frame = self.yellowBox.frame
frame.origin.x = frame.origin.x - 100
self.yellowBox.frame = frame
}, completion: nil)
}
@IBAction func rightButtonTapped(_ sender: Any) {
UIView.animate(withDuration: 0.5, animations: {
var frame = self.yellowBox.frame
frame.origin.x = frame.origin.x + 100
self.yellowBox.frame = frame
}, completion: nil)
}
@IBAction func upButtonTapped(_ sender: Any) {
UIView.animate(withDuration: 0.5, animations: {
var frame = self.yellowBox.frame
frame.origin.y = frame.origin.y - 100
extension ViewController {
@IBAction func leftButtonTapped(_ sender: Any) {
UIView.animate(withDuration: 0.5, animations: {
var frame = self.yellowBox.frame
frame.origin.x = frame.origin.x - 100
self.yellowBox.frame = frame
}, completion: nil)
}
@IBAction func rightButtonTapped(_ sender: Any) {
UIView.animate(withDuration: 0.5, animations: {
var frame = self.yellowBox.frame
frame.origin.x = frame.origin.x + 100
self.yellowBox.frame = frame
}, completion: nil)
}
@IBAction func upButtonTapped(_ sender: Any) {
UIView.animate(withDuration: 0.5, animations: {
var frame = self.yellowBox.frame
frame.origin.y = frame.origin.y - 100
self.yellowBox.frame = frame
}, completion: nil)
}
@IBAction func downButtonTapped(_ sender: Any) {
UIView.animate(withDuration: 0.5, animations: {
var frame = self.yellowBox.frame
frame.origin.y = frame.origin.y + 100
self.yellowBox.frame = frame
}, completion: nil)
}
}
enum AnimationDirection {
case up
case down
case left
case right
}
extension ViewController {
func moveBox(to: AnimationDirection) -> () -> Void {
return {
var frame = self.yellowBox.frame
switch to {
case .left:
frame.origin.x = frame.origin.x - 100
case .right:
frame.origin.x = frame.origin.x + 100
case .down:
frame.origin.y = frame.origin.y + 100
case .up:
frame.origin.y = frame.origin.y - 100
}
self.yellowBox.frame = frame
}
}
@IBAction func leftButtonTapped(_ sender: Any) {
frame.origin.x = frame.origin.x + 100
case .down:
frame.origin.y = frame.origin.y + 100
case .up:
frame.origin.y = frame.origin.y - 100
}
self.yellowBox.frame = frame
}
}
@IBAction func leftButtonTapped(_ sender: Any) {
UIView.animate(withDuration: 0.5,
animations: moveBox(to: .left),
completion: nil)
}
@IBAction func rightButtonTapped(_ sender: Any) {
UIView.animate(withDuration: 0.5,
animations: moveBox(to: .right),
completion: nil)
}
@IBAction func upButtonTapped(_ sender: Any) {
UIView.animate(withDuration: 0.5,
animations: moveBox(to: .up),
completion: nil)
}
@IBAction func downButtonTapped(_ sender: Any) {
UIView.animate(withDuration: 0.5,
animations: moveBox(to: .down),
completion: nil)
}
}
viewController.api = { (pageID: Int) -> Observable<[Post]> in
// alamofire api Observable Return
}
viewController.api = { (pageID: Int) -> Observable<[Post]> in
// alamofire api Observable Return
}
func searchAPI(searchText: String) -> (Int) -> Observable<[Post]>
self.api = searchAPI(searchText: "search keywords")
func curry<A, B, C>(f: @escaping (A, B) -> C) -> ((A) -> ((B) -> C)) {
return { x in { y in f(x, y) }}
}
func fiveTimeCurry<A, B, C, D, E>(_ a: A) -> (B) -> (C) -> (D) -> E {
}
g(f(x))
g(f(x))
let result = bind(add2, 3) // result => 5
g(f(x))
let result = bind(add2, 3) // result => 5
infix operator >>=: MultiplicationPrecedence
func >>=<A, B>(a: A, f: (A) -> B) -> B
?

Contenu connexe

Tendances

Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxEleanor McHugh
 
Introduction to Swift programming language.
Introduction to Swift programming language.Introduction to Swift programming language.
Introduction to Swift programming language.Icalia Labs
 
Type Driven Development with TypeScript
Type Driven Development with TypeScriptType Driven Development with TypeScript
Type Driven Development with TypeScriptGarth Gilmour
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming LanguageGiuseppe Arici
 
Swift Rocks #2: Going functional
Swift Rocks #2: Going functionalSwift Rocks #2: Going functional
Swift Rocks #2: Going functionalHackraft
 
Synapse india complain sharing info about php chaptr 26
Synapse india complain sharing info about php chaptr 26Synapse india complain sharing info about php chaptr 26
Synapse india complain sharing info about php chaptr 26SynapseindiaComplaints
 
Swift rocks! #1
Swift rocks! #1Swift rocks! #1
Swift rocks! #1Hackraft
 
Funcitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayFuncitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayNatasha Murashev
 
Programming Language Swift Overview
Programming Language Swift OverviewProgramming Language Swift Overview
Programming Language Swift OverviewKaz Yoshikawa
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedSusan Potter
 
Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)David de Boer
 
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей КоваленкоFwdays
 
PHP Functions & Arrays
PHP Functions & ArraysPHP Functions & Arrays
PHP Functions & ArraysHenry Osborne
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?osfameron
 
PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language TriviaNikita Popov
 
A Few Interesting Things in Apple's Swift Programming Language
A Few Interesting Things in Apple's Swift Programming LanguageA Few Interesting Things in Apple's Swift Programming Language
A Few Interesting Things in Apple's Swift Programming LanguageSmartLogic
 

Tendances (20)

Php & my sql
Php & my sqlPhp & my sql
Php & my sql
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Introduction to Swift programming language.
Introduction to Swift programming language.Introduction to Swift programming language.
Introduction to Swift programming language.
 
Type Driven Development with TypeScript
Type Driven Development with TypeScriptType Driven Development with TypeScript
Type Driven Development with TypeScript
 
Developing iOS apps with Swift
Developing iOS apps with SwiftDeveloping iOS apps with Swift
Developing iOS apps with Swift
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming Language
 
Swift Rocks #2: Going functional
Swift Rocks #2: Going functionalSwift Rocks #2: Going functional
Swift Rocks #2: Going functional
 
Synapse india complain sharing info about php chaptr 26
Synapse india complain sharing info about php chaptr 26Synapse india complain sharing info about php chaptr 26
Synapse india complain sharing info about php chaptr 26
 
Swift rocks! #1
Swift rocks! #1Swift rocks! #1
Swift rocks! #1
 
Funcitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayFuncitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional Way
 
Programming Language Swift Overview
Programming Language Swift OverviewProgramming Language Swift Overview
Programming Language Swift Overview
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids Applied
 
Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)
 
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
 
ECMAScript 6
ECMAScript 6ECMAScript 6
ECMAScript 6
 
PHP Functions & Arrays
PHP Functions & ArraysPHP Functions & Arrays
PHP Functions & Arrays
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?
 
PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language Trivia
 
A Few Interesting Things in Apple's Swift Programming Language
A Few Interesting Things in Apple's Swift Programming LanguageA Few Interesting Things in Apple's Swift Programming Language
A Few Interesting Things in Apple's Swift Programming Language
 
EcmaScript 6
EcmaScript 6 EcmaScript 6
EcmaScript 6
 

Similaire à Swift 함수 커링 사용하기

Go: It's Not Just For Google
Go: It's Not Just For GoogleGo: It's Not Just For Google
Go: It's Not Just For GoogleEleanor McHugh
 
Swift the implicit parts
Swift the implicit partsSwift the implicit parts
Swift the implicit partsMaxim Zaks
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)riue
 
Hitchhiker's Guide to Functional Programming
Hitchhiker's Guide to Functional ProgrammingHitchhiker's Guide to Functional Programming
Hitchhiker's Guide to Functional ProgrammingSergey Shishkin
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kirill Rozov
 
7 Habits For a More Functional Swift
7 Habits For a More Functional Swift7 Habits For a More Functional Swift
7 Habits For a More Functional SwiftJason Larsen
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming iiPrashant Kalkar
 
Generics and Inference
Generics and InferenceGenerics and Inference
Generics and InferenceRichard Fox
 
Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3Kirill Rozov
 
Swift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdfSwift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdfJkPoppy
 
Monadologie
MonadologieMonadologie
Monadologieleague
 
Functions In Scala
Functions In Scala Functions In Scala
Functions In Scala Knoldus Inc.
 
TDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
TDC218SP | Trilha Kotlin - DSLs in a Kotlin WayTDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
TDC218SP | Trilha Kotlin - DSLs in a Kotlin Waytdc-globalcode
 
Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meetMario Fusco
 
Swift 3.0 の新しい機能(のうちの9つ)
Swift 3.0 の新しい機能(のうちの9つ)Swift 3.0 の新しい機能(のうちの9つ)
Swift 3.0 の新しい機能(のうちの9つ)Tomohiro Kumagai
 

Similaire à Swift 함수 커링 사용하기 (20)

Pooya Khaloo Presentation on IWMC 2015
Pooya Khaloo Presentation on IWMC 2015Pooya Khaloo Presentation on IWMC 2015
Pooya Khaloo Presentation on IWMC 2015
 
Go: It's Not Just For Google
Go: It's Not Just For GoogleGo: It's Not Just For Google
Go: It's Not Just For Google
 
Swift the implicit parts
Swift the implicit partsSwift the implicit parts
Swift the implicit parts
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
 
Hitchhiker's Guide to Functional Programming
Hitchhiker's Guide to Functional ProgrammingHitchhiker's Guide to Functional Programming
Hitchhiker's Guide to Functional Programming
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2
 
7 Habits For a More Functional Swift
7 Habits For a More Functional Swift7 Habits For a More Functional Swift
7 Habits For a More Functional Swift
 
Benefits of Kotlin
Benefits of KotlinBenefits of Kotlin
Benefits of Kotlin
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming ii
 
Generics and Inference
Generics and InferenceGenerics and Inference
Generics and Inference
 
Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3
 
Swift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdfSwift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdf
 
Monadologie
MonadologieMonadologie
Monadologie
 
Functions In Scala
Functions In Scala Functions In Scala
Functions In Scala
 
Scala best practices
Scala best practicesScala best practices
Scala best practices
 
TDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
TDC218SP | Trilha Kotlin - DSLs in a Kotlin WayTDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
TDC218SP | Trilha Kotlin - DSLs in a Kotlin Way
 
Python : Functions
Python : FunctionsPython : Functions
Python : Functions
 
Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meet
 
Swift 3.0 の新しい機能(のうちの9つ)
Swift 3.0 の新しい機能(のうちの9つ)Swift 3.0 の新しい機能(のうちの9つ)
Swift 3.0 の新しい機能(のうちの9つ)
 

Dernier

Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 

Dernier (20)

Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 

Swift 함수 커링 사용하기

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12. func ( : ) -> (( ) -> )
  • 13. func ( : ) -> ( ) ->
  • 14.
  • 15.
  • 16.
  • 17.
  • 18. func add(_ value1: Int, _ value2: Int) -> Int { return value1 + value2 } add(2,3)
  • 19. func curriedAdd(_ value1: Int) -> ( (Int) -> Int ) { return { value2 in return value1 + value2 } }
  • 20. func curriedAdd(_ value1: Int) -> ( (Int) -> Int ) { return { value2 in return value1 + value2 } } let add2 = curriedAdd(2) add2(3)
  • 21. func curriedAdd(_ value1: Int) -> ( (Int) -> Int ) { return { value2 in return value1 + value2 } } let add2 = curriedAdd(2) add2(3) curriedAdd(2)(3)
  • 22. let add2 = curriedAdd(2) add2(3) curriedAdd(2)(3) func curriedAdd(_ value1: Int) -> (Int) -> Int { return { value2 in return value1 + value2 } }
  • 23.
  • 25. func stringDevider(_ seperater: String) -> (String) -> [String] { return { (string: String) -> [String] in return string.components(separatedBy: seperater) } } let stringDevideBySlash = stringDevider("/") let stringDevideByAsterisk = stringDevider("*") stringDevideBySlash("aaa/bbb/ccc/ddd") stringDevideByAsterisk("aaa*bbb*ccc*ddd")
  • 26.
  • 27.
  • 28. class SomeClass { func someFunction() { } }
  • 29. class SomeClass { func someFunction() { } } let someinstance = SomeClass() someinstance.someFunction()
  • 30. class SomeClass { func someFunction() { } } let someinstance = SomeClass() someinstance.someFunction()
  • 31. class SomeClass { func someFunction() { } } let someinstance = SomeClass() someinstance.someFunction()
  • 32. class SomeClass { func someFunction() { } } let someinstance = SomeClass() someinstance.someFunction()
  • 33. class SomeClass { func someFunction() { } } let someinstance = SomeClass() someinstance.someFunction() SomeClass.someFunction(someinstance)()
  • 34. class SomeClass { func someFunction() { } } let someinstance = SomeClass() someinstance.someFunction() SomeClass.someFunction(someinstance)()
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40. func regexTest(pattern: String) -> (String) -> Bool
  • 41. { let expression: NSRegularExpression? = try? NSRegularExpression(pattern: pattern, options: .caseInsensitive) return { (input: String) -> Bool in guard let expression = expression else { return false } let inputRange = NSMakeRange(0, input.characters.count) let matches = expression.matches(in: input, options: [], range: inputRange) return matches.count > 0 } } func regexTest(pattern: String) -> (String) -> Bool
  • 42. { let expression: NSRegularExpression? = try? NSRegularExpression(pattern: pattern, options: .caseInsensitive) return { (input: String) -> Bool in guard let expression = expression else { return false } let inputRange = NSMakeRange(0, input.characters.count) let matches = expression.matches(in: input, options: [], range: inputRange) return matches.count > 0 } } func regexTest(pattern: String) -> (String) -> Bool regexTest(pattern: "main")("int main()")
  • 43. { let expression: NSRegularExpression? = try? NSRegularExpression(pattern: pattern, options: .caseInsensitive) return { (input: String) -> Bool in guard let expression = expression else { return false } let inputRange = NSMakeRange(0, input.characters.count) let matches = expression.matches(in: input, options: [], range: inputRange) return matches.count > 0 } } func regexTest(pattern: String) -> (String) -> Bool regexTest(pattern: "main")("int main()") let hasMainIn = regexTest(pattern: "main") hasMainIn("int main()")
  • 44.
  • 45. class Regex { var internalExpression: NSRegularExpression? init(_ pattern: String) { self.internalExpression = try? NSRegularExpression(pattern: pattern, options: .caseInsensitive) } func test(_ input: String) -> Bool { let inputRange = NSMakeRange(0, input.characters.count) guard let matchesCount = self.internalExpression? .matches(in: input, options: [], range:inputRange) .count else { return false } return matchesCount > 0 } }
  • 46. class Regex { var internalExpression: NSRegularExpression? init(_ pattern: String) { self.internalExpression = try? NSRegularExpression(pattern: pattern, options: .caseInsensitive) } func test(_ input: String) -> Bool { let inputRange = NSMakeRange(0, input.characters.count) guard let matchesCount = self.internalExpression? .matches(in: input, options: [], range:inputRange) .count else { return false } return matchesCount > 0 } } let regex = Regex("main") regex.test("int main()") Regex("main").test("int main()")
  • 47. class Regex { var internalExpression: NSRegularExpression? init(_ pattern: String) { self.internalExpression = try? NSRegularExpression(pattern: pattern, options: .caseInsensitive) } func test(_ input: String) -> Bool { let inputRange = NSMakeRange(0, input.characters.count) guard let matchesCount = self.internalExpression? .matches(in: input, options: [], range:inputRange) .count else { return false } return matchesCount > 0 } } let regex = Regex("main") regex.test("int main()") Regex("main").test("int main()") let hasMainIn = Regex("main").test hasMainIn("int main()")
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53. struct Friend { var name: String var id: Int }
  • 54. struct Friend { var name: String var id: Int } let friends = [Friend(name:" ", id: 1), Friend(name:" ", id: 2), Friend(name:" ", id: 3), Friend(name:" ", id: 4), Friend(name:" ", id: 5)]
  • 55. struct Friend { var name: String var id: Int } let friends = [Friend(name:" ", id: 1), Friend(name:" ", id: 2), Friend(name:" ", id: 3), Friend(name:" ", id: 4), Friend(name:" ", id: 5)] func inviteFriend(ID: Int) -> Void
  • 56. let actionsheet = UIAlertController(title: " ", message: " ", preferredStyle: .actionSheet)
  • 57. let actionsheet = UIAlertController(title: " ", message: " ", preferredStyle: .actionSheet) UIAlertAction(title: String?, style: UIAlertActionStyle, handler: ((UIAlertAction) -> Void)?)
  • 58. func actionHandler(friendID: Int) -> (UIAlertAction) -> () { return { [weak self] action -> Void in self?.inviteFriend(ID: friendID) } } friends.forEach{ (friend: Friend) in actionsheet.addAction(UIAlertAction(title: friend.name, style: UIAlertActionStyle.default, handler: actionHandler(friendID: friend.id))) } actionsheet.addAction(UIAlertAction(title: " ", style: .cancel, handler: nil))
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67. class ViewController: UIViewController { @IBOutlet var yellowBox: UIView! }
  • 68. class ViewController: UIViewController { @IBOutlet var yellowBox: UIView! } extension ViewController { @IBAction func leftButtonTapped(_ sender: Any) { UIView.animate(withDuration: 0.5, animations: { var frame = self.yellowBox.frame frame.origin.x = frame.origin.x - 100 self.yellowBox.frame = frame }, completion: nil) } @IBAction func rightButtonTapped(_ sender: Any) { UIView.animate(withDuration: 0.5, animations: { var frame = self.yellowBox.frame frame.origin.x = frame.origin.x + 100 self.yellowBox.frame = frame }, completion: nil) } @IBAction func upButtonTapped(_ sender: Any) { UIView.animate(withDuration: 0.5, animations: { var frame = self.yellowBox.frame frame.origin.y = frame.origin.y - 100
  • 69. extension ViewController { @IBAction func leftButtonTapped(_ sender: Any) { UIView.animate(withDuration: 0.5, animations: { var frame = self.yellowBox.frame frame.origin.x = frame.origin.x - 100 self.yellowBox.frame = frame }, completion: nil) } @IBAction func rightButtonTapped(_ sender: Any) { UIView.animate(withDuration: 0.5, animations: { var frame = self.yellowBox.frame frame.origin.x = frame.origin.x + 100 self.yellowBox.frame = frame }, completion: nil) } @IBAction func upButtonTapped(_ sender: Any) { UIView.animate(withDuration: 0.5, animations: { var frame = self.yellowBox.frame frame.origin.y = frame.origin.y - 100 self.yellowBox.frame = frame }, completion: nil) } @IBAction func downButtonTapped(_ sender: Any) { UIView.animate(withDuration: 0.5, animations: { var frame = self.yellowBox.frame frame.origin.y = frame.origin.y + 100 self.yellowBox.frame = frame }, completion: nil) } }
  • 70. enum AnimationDirection { case up case down case left case right } extension ViewController { func moveBox(to: AnimationDirection) -> () -> Void { return { var frame = self.yellowBox.frame switch to { case .left: frame.origin.x = frame.origin.x - 100 case .right: frame.origin.x = frame.origin.x + 100 case .down: frame.origin.y = frame.origin.y + 100 case .up: frame.origin.y = frame.origin.y - 100 } self.yellowBox.frame = frame } } @IBAction func leftButtonTapped(_ sender: Any) {
  • 71. frame.origin.x = frame.origin.x + 100 case .down: frame.origin.y = frame.origin.y + 100 case .up: frame.origin.y = frame.origin.y - 100 } self.yellowBox.frame = frame } } @IBAction func leftButtonTapped(_ sender: Any) { UIView.animate(withDuration: 0.5, animations: moveBox(to: .left), completion: nil) } @IBAction func rightButtonTapped(_ sender: Any) { UIView.animate(withDuration: 0.5, animations: moveBox(to: .right), completion: nil) } @IBAction func upButtonTapped(_ sender: Any) { UIView.animate(withDuration: 0.5, animations: moveBox(to: .up), completion: nil) } @IBAction func downButtonTapped(_ sender: Any) { UIView.animate(withDuration: 0.5, animations: moveBox(to: .down), completion: nil) } }
  • 72.
  • 73. viewController.api = { (pageID: Int) -> Observable<[Post]> in // alamofire api Observable Return }
  • 74. viewController.api = { (pageID: Int) -> Observable<[Post]> in // alamofire api Observable Return } func searchAPI(searchText: String) -> (Int) -> Observable<[Post]> self.api = searchAPI(searchText: "search keywords")
  • 75. func curry<A, B, C>(f: @escaping (A, B) -> C) -> ((A) -> ((B) -> C)) { return { x in { y in f(x, y) }} } func fiveTimeCurry<A, B, C, D, E>(_ a: A) -> (B) -> (C) -> (D) -> E { }
  • 76.
  • 78. g(f(x)) let result = bind(add2, 3) // result => 5
  • 79. g(f(x)) let result = bind(add2, 3) // result => 5 infix operator >>=: MultiplicationPrecedence func >>=<A, B>(a: A, f: (A) -> B) -> B
  • 80. ?