SlideShare ist ein Scribd-Unternehmen logo
1 von 80
Downloaden Sie, um offline zu lesen
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
?

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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つ)
 

Kürzlich hochgeladen

Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 

Kürzlich hochgeladen (20)

Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 

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. ?