The document discusses various idioms in Swift including optional binding with guard let and if let, nil coalescing operator, switch statements with optionals and associated values, closures, lazy properties, and computed properties with property observers. Key idioms covered include using guard let to ensure non-nil arguments, extracting associated values from enums using switch, initializing immutable variables with closures, and updating for loops to the Swift 3 syntax.
Stanfy MadCode Meetup #9: Functional Programming 101 with SwiftStanfy
This time Alexander Voronov (@aleks_voronov), iOS Developer at Stanfy talked about Functional Programming 101 with Swift
Key points:
- Why do we need Functional Programming?
- The power of Swift
- Functors, Applicatives and Monads
- Pipes & Railways
- Functional Swift in real life
Links Mentioned:
- Functors, Applicatives and Monads in Pictures: http://adit.io/posts/2013-04-17-funct...
- Railway Oriented Programming: http://fsharpforfunandprofit.com/post...
- Functional Programming in Swift (Objc.io): http://www.objc.io/books/fpinswift/
- Moya: https://github.com/Moya/Moya
- Argo: https://github.com/thoughtbot/Argo
- Swiftz: https://github.com/typelift/Swiftz
- RxSwift: https://github.com/ReactiveX/RxSwift
- ReactiveCocoa-3.0: https://github.com/ReactiveCocoa/Reac...
- Haskell: https://www.haskell.org
- F#: http://fsharp.org
- Erlang: http://www.erlang.org
- Elm: http://elm-lang.org
Watch video from the presentation (rus): https://youtu.be/w6zyGylS4Wk
Join our MadCode group on FB(rus): https://www.facebook.com/MadCodeMeetup/
Find more videos from MadCode Meetups (rus): https://www.youtube.com/playlist?list=PLrplqd3YJvBvUygFkx4Xvx1p3zyiCgB9Q
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFabio Collini
Kotlin is a first-class language for Android development since Google I/O 2017. And it’s here to stay!
Thanks to Android Studio it’s really easy to introduce Kotlin in an existing project, the configuration is trivial and then we can convert Java classes to Kotlin using a Alt+Shift+Cmd+K. But the new syntax is the just beginning, using Kotlin we can improve our code making it more readable and simpler to write.
In this talk we’ll see how to use some Kotlin features (for example data classes, collections, coroutines and delegates) to simplify Android development comparing the code with the equivalent “modern” Java code. It’s not fair to compare Kotlin code with plain Java 6 code so the Java examples will use lambdas and some external libraries like RxJava and AutoValue.
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFabio Collini
Kotlin is a first-class language for Android development since Google I/O 2017. And it’s here to stay!
Thanks to Android Studio it’s really easy to introduce Kotlin in an existing project, the configuration is trivial and then we can convert Java classes to Kotlin using a Alt+Shift+Cmd+K. But the new syntax is the just beginning, using Kotlin we can improve our code making it more readable and simpler to write.
In this talk we’ll see how to use some Kotlin features (for example data classes, collections, coroutines and delegates) to simplify Android development comparing the code with the equivalent “modern” Java code. It’s not fair to compare Kotlin code with plain Java 6 code so the Java examples will use lambdas and some external libraries like RxJava and AutoValue.
Taking Perl to Eleven with Higher-Order FunctionsDavid Golden
Sometimes, you just need your Perl to go one higher. This talk will teach you how to use functions that return functions for powerful, succinct solutions to some repetitive coding problems. Along the way, you’ll see concrete examples using higher-order Perl to generate declarative, structured “fake” data for testing.
FunScript/F# is the only statically-typed compile-to-js language poised to take full advantage of the JavaScript ecosystem. F#'s type providers make consuming JavaScript possible without any code generation or foreign function interface definition. FunScript has taken the first steps to making this a reality by consuming TypeScript definitions files. However, the F# community has more ambitious plans to consume pure JavaScript files too. Seamless integration with the node package manager might also be on the horizon. Find out more at: http://funscript.info/ http://fsharp.org/ and http://zbray.com/
L'approche CRUD pour la gestion des données est souvent utilisée dans nos projet. Que met-on met généralement derrière ce terme ? Quels avantages et quels risques à utiliser CRUD ? Quelles autres approches ?
Présenter lors du Meetup de AFUP Montpellier le 28/10/2020
https://www.youtube.com/watch?v=gCcDt3TLA-o
To understand deep hart of Swift Programming, try programming Shogi - Jpanaese Chess - to find out the pros and cons of Swift language. Still experimental implementation but there some interesting stories and can be shared with audience.
Stanfy MadCode Meetup #9: Functional Programming 101 with SwiftStanfy
This time Alexander Voronov (@aleks_voronov), iOS Developer at Stanfy talked about Functional Programming 101 with Swift
Key points:
- Why do we need Functional Programming?
- The power of Swift
- Functors, Applicatives and Monads
- Pipes & Railways
- Functional Swift in real life
Links Mentioned:
- Functors, Applicatives and Monads in Pictures: http://adit.io/posts/2013-04-17-funct...
- Railway Oriented Programming: http://fsharpforfunandprofit.com/post...
- Functional Programming in Swift (Objc.io): http://www.objc.io/books/fpinswift/
- Moya: https://github.com/Moya/Moya
- Argo: https://github.com/thoughtbot/Argo
- Swiftz: https://github.com/typelift/Swiftz
- RxSwift: https://github.com/ReactiveX/RxSwift
- ReactiveCocoa-3.0: https://github.com/ReactiveCocoa/Reac...
- Haskell: https://www.haskell.org
- F#: http://fsharp.org
- Erlang: http://www.erlang.org
- Elm: http://elm-lang.org
Watch video from the presentation (rus): https://youtu.be/w6zyGylS4Wk
Join our MadCode group on FB(rus): https://www.facebook.com/MadCodeMeetup/
Find more videos from MadCode Meetups (rus): https://www.youtube.com/playlist?list=PLrplqd3YJvBvUygFkx4Xvx1p3zyiCgB9Q
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFabio Collini
Kotlin is a first-class language for Android development since Google I/O 2017. And it’s here to stay!
Thanks to Android Studio it’s really easy to introduce Kotlin in an existing project, the configuration is trivial and then we can convert Java classes to Kotlin using a Alt+Shift+Cmd+K. But the new syntax is the just beginning, using Kotlin we can improve our code making it more readable and simpler to write.
In this talk we’ll see how to use some Kotlin features (for example data classes, collections, coroutines and delegates) to simplify Android development comparing the code with the equivalent “modern” Java code. It’s not fair to compare Kotlin code with plain Java 6 code so the Java examples will use lambdas and some external libraries like RxJava and AutoValue.
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFabio Collini
Kotlin is a first-class language for Android development since Google I/O 2017. And it’s here to stay!
Thanks to Android Studio it’s really easy to introduce Kotlin in an existing project, the configuration is trivial and then we can convert Java classes to Kotlin using a Alt+Shift+Cmd+K. But the new syntax is the just beginning, using Kotlin we can improve our code making it more readable and simpler to write.
In this talk we’ll see how to use some Kotlin features (for example data classes, collections, coroutines and delegates) to simplify Android development comparing the code with the equivalent “modern” Java code. It’s not fair to compare Kotlin code with plain Java 6 code so the Java examples will use lambdas and some external libraries like RxJava and AutoValue.
Taking Perl to Eleven with Higher-Order FunctionsDavid Golden
Sometimes, you just need your Perl to go one higher. This talk will teach you how to use functions that return functions for powerful, succinct solutions to some repetitive coding problems. Along the way, you’ll see concrete examples using higher-order Perl to generate declarative, structured “fake” data for testing.
FunScript/F# is the only statically-typed compile-to-js language poised to take full advantage of the JavaScript ecosystem. F#'s type providers make consuming JavaScript possible without any code generation or foreign function interface definition. FunScript has taken the first steps to making this a reality by consuming TypeScript definitions files. However, the F# community has more ambitious plans to consume pure JavaScript files too. Seamless integration with the node package manager might also be on the horizon. Find out more at: http://funscript.info/ http://fsharp.org/ and http://zbray.com/
L'approche CRUD pour la gestion des données est souvent utilisée dans nos projet. Que met-on met généralement derrière ce terme ? Quels avantages et quels risques à utiliser CRUD ? Quelles autres approches ?
Présenter lors du Meetup de AFUP Montpellier le 28/10/2020
https://www.youtube.com/watch?v=gCcDt3TLA-o
To understand deep hart of Swift Programming, try programming Shogi - Jpanaese Chess - to find out the pros and cons of Swift language. Still experimental implementation but there some interesting stories and can be shared with audience.
Central sensitization as normal response to injuryArturo Such Sanz
Descripción de la respuesta fisiológica de sensibilización central en respuesta a una activación de la nocicepción y su correlato consciente en forma de dolor.
Criterios de valoración de una lesión sensibilización central patológica o potencialmente patológica, especialmente en dolor lumbar y latigazo cervical. Extrapolación a la mano.
In this talk, Adrian Kashivskyy, Netguru iOS Developer, digs into rarely discussed Swift features, such as literal convertibles, interpolation convertibles, pattern matching, reflection and advanced Objective-C bridging.
Python's "batteries included" philosophy means that it comes with an astonishing amount of great stuff. On top of that, there's a vibrant world of third-party libraries that help make Python even more wonderful. We'll go on a breezy, example-filled tour through some of my favorites, from treasures in the standard library to great third-party packages that I don't think I could live without, and we'll touch on some of the fuzzier aspects of the Python culture that make it such a joy to be part of.
Apple's Swift has achieved the top place in Stack Overflow's "Most Loved" list of programming languages in its 2015 Developer Survey. Based on information gleaned from GitHub and Stack Overflow, analyst firm RedMonk has seen Swift's popularity ranking soar from 68 to 22 in an unprecedented 6 months.
The "Extreme Swift" event does not require advanced, or even any, knowledge of Swift. Learn about some of the more outrageous features of the language which help explain what the fuss is all about!
Never look at programming the same way again — even if you never end up writing a single line of Swift code in your life.
OSCON Presentation: Developing High Performance Websites and Modern Apps with...Doris Chen
Creating high performance sites and apps is crucial for every developer. In this session, we will explore the best practices and performance tricks, including startup time, UI responsiveness, and Memory efficiency to make your apps running faster and fluid. Come learn the tips, tricks, and tools for maximizing the performance of your sites and apps with JavaScript and HTML5.
iOS Development using Swift: Enums, ARC, Delegation, Closures, Table View and...Ahmed Ali
Learn iOS development using Swift (Arabic tutorials) - Fourth session slides, which covers the following topics:
- Enumerations
- Auto References Count (ARC)
- Delegation Pattern
- Closures
.
The video end up demonstrating: UITableView, performing segues programmatically, passing data between screens, and access information on iOS Documentation.
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
8. guard let
• 二つの引数が nil でない事を保証する
func add(a: Int?, _ b: Int?) -> Int? {
guard let a = a, let b = b else { return nil }
return a + b
}
9. if let
• if let を使う
func add(a: Int?, _ b: Int?) -> Int? {
if let a = a, let b = b {
return a + b
}
return nil
}
10. where
• guard let で0以上を保証する
func add(a: Int?, _ b: Int?) -> Int? {
guard let a = a, let b = b where a >= 0 && b >= 0 else {
return nil
}
return a + b
}
• if let でも0以上を保証する
func add(a: Int?, _ b: Int?) -> Int? {
if let a = a, let b = b where a >= 0 && b >= 0 {
return a + b
}
return nil
}
13. Optional in Switch
• 実は optional も switch 文に使える
func countryName(identifier: String?) -> String? {
switch identifier {
case "JP"?: return "Japan"
case "GB"?: return "England"
case "US"?: return "U.S.A."
default: return nil
}
}
14. Late Initializing
Immutable Variables
• 初期値を後で設定する不定変数
let color: UIColor // "= value"
switch value % 3 {
case 0: color = UIColor.whiteColor()
case 1: color = UIColor.redColor()
default: fatalError()
}
• 初期化しないケースがあると、コンパイルエラー
15. Complex switch cases
for thing in things {
switch thing {
case 0 as Int:
print("zero as an Int")
case 0 as Double:
print("zero as a Double")
case let someInt as Int:
print("an integer value of (someInt)")
case let someDouble as Double where someDouble > 0:
print("a positive double value of (someDouble)")
case is Double:
print("some other double value")
case let someString as String:
print("a string value of "(someString)"")
case let (x, y) as (Double, Double):
print("an (x, y) point at (x), (y)")
case let movie as Movie:
print("Movie:'(movie.name)'")
default:
print("something else")
}
}
20. Defining Associated
Value
enum Element {
case String(Swift.String)
case Boolean(Bool)
case Integer(Int)
case Float(Swift.Float)
case Dictionary([Swift.String: Element])
case Array([Element])
case Null
}
let integer = Element.Integer(42)
let city = Element.String("Tokyo")
let cities = Element.Array([city])
let dictionary = Element.Dictionary(["items": array])
21. Extracting Associated Values
Using switch Statement
• Associated Value を Switch文で取り出す
switch element {
case .String(let string): print("string: (string)")
case .Boolean(let value): print("boolean: (value)")
case .Integer(let value): print("ineteger: (value)")
case .Float(let value): print("float: (value)")
case .Dictionary(let dictionary):
print("dictionary: (dictionary)")
case .Array(let array): print("array: (array)")
case .Null: print("null")
}
22. Extracting Associated
Values using if Statement
• If 文でも取り出せます
let element1: Element = …
if case .String(let string) = element1 {
print("(string)")
}
• Optional な場合でも取り出せます
let element: Element? = …
if case .String(let string)? = element1 {
print("(string)")
}
23. Extracting Associated
Values
• division -> members -> person -> name
let name = Element.String("John")
let john = Element.Dictionary(["name": name])
let members = Element.Array([john])
let group = Element.Dictionary(["members": members])
• 一発で取り出せる
if case .Dictionary(let group) = group,
case .Array(let members)? = division["members"],
case .Dictionary(let member)? = members.first,
case .String(let name)? = member["name"] {
print("(name)") // John
}
39. Singleton
• 典型的なシングルトン
class Manager {
static let sharedManager = Manager()
private init() {
}
}
• クロージャーを使ったシングルトン
class Manager {
static var sharedManager: Manager = {
return Manager()
}()
private init() {
}
}
http://qiita.com/codelynx/items/a936afe0a45d4cf5abfb
40. Updating C style
`for` statement
http://qiita.com/codelynx/items/899c26dd2cbdba7d2b00
41. for var i = 0 ; i < 100 ; i++
// C-Style for statement
for var i = 0 ; i < 100 ; i++ {
print("(i)")
}
// Swift 3.0 ready
(0 ..< 100).forEach { print("($0)") }
// Swift 3.0 ready
for i in (0 ..< 100) {
print("(i)")
}
42. for var i = 99 ; i >= 0 ; i--
// C-Style for statement
for var i = 99 ; i >= 0 ; i-- {
print("(i)")
}
// Swift 3.0 ready
(0 ..< 100).reverse().forEach { print("($0)") }
// Swift 3.0 ready
for i in (0 ..< 100).reverse() {
print("(i)")
}
43. for var i = 0; i < 100 ; i += 2
// C-Style for statement
for var i = 0; i < 100 ; i += 2 {
print("(i)")
}
// Swift 3.0 ready
0.stride(to: 100, by: 2).forEach { print("($0)") }
44. for var i = 98 ; i >= 0 ; i -=
2
// C-Style for statement
for var i = 98 ; i >= 0 ; i -= 2 {
print("(i)")
}
// Swift 3.0 ready
98.stride(through: 0, by: -2).forEach { print("($0)") }
// Swift 3.0 ready
0.stride(to: 100, by: 2).reverse().forEach { print("($0)") }
// Swift 3.0 ready
for i in 0.stride(to: 100, by: 2).reverse() {
print("(i)")
}
45. for without increment
• 次の再初期化式の指定がなく、刻みが不定の場合
// C-Style for statement
for var i = 0 ; i < 100 ; {
print("(i)")
if (i * i) % 2 == 0 { i += 1 }
else { i += 2 }
}
// Swift 3.0 ready
var i = 0
while i < 100 {
print("(i)")
if (i * i) % 2 == 0 { i += 1 }
else { i += 2 }
}