SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
xxxLiteralConvertible
@taketo1024
2015/02/18 potatotips #14
http://maths4pg.connpass.com
2014/10/18 「iOS 8 / Swift 勉強会 @ ヤフー」
import Foundation
struct Complex: Equatable, IntegerLiteralConvertible, FloatLiteralConvertible {
let x: Double
let y: Double
init(_ x: Double, _ y: Double) {
self.x = x
self.y = y
}
init(_ x: Double) {
self.x = x
self.y = 0
}
init(integerLiteral x: IntegerLiteralType) {
self.x = Double(x)
self.y = 0
}
init(floatLiteral x: FloatLiteralType) {
self.x = x
self.y = 0
}
init(r: Double, θ: Double) {
self.x = r * cos(θ)
self.y = r * sin(θ)
}
}
func == (z: Complex, w: Complex) -> Bool {
return z.x == w.x && z.y == w.y
}
func Re(a: Complex) -> Double {
return a.x
}
func Im(a: Complex) -> Double {
import Foundation
struct Complex: Equatable, IntegerLiteralConvertible, FloatLiteralConvertible {
let x: Double
let y: Double
init(_ x: Double, _ y: Double) {
self.x = x
self.y = y
}
init(_ x: Double) {
self.x = x
self.y = 0
}
init(integerLiteral x: IntegerLiteralType) {
self.x = Double(x)
self.y = 0
}
init(floatLiteral x: FloatLiteralType) {
self.x = x
self.y = 0
}
init(r: Double, θ: Double) {
self.x = r * cos(θ)
self.y = r * sin(θ)
}
}
func == (z: Complex, w: Complex) -> Bool {
return z.x == w.x && z.y == w.y
}
func Re(a: Complex) -> Double {
return a.x
}
func Im(a: Complex) -> Double {
import Foundation
struct Complex: Equatable, IntegerLiteralConvertible, FloatLiteralConvertible {
let x: Double
let y: Double
init(_ x: Double, _ y: Double) {
self.x = x
self.y = y
}
init(_ x: Double) {
self.x = x
self.y = 0
}
init(integerLiteral x: IntegerLiteralType) {
self.x = Double(x)
self.y = 0
}
init(floatLiteral x: FloatLiteralType) {
self.x = x
self.y = 0
}
init(r: Double, θ: Double) {
self.x = r * cos(θ)
self.y = r * sin(θ)
}
}
func == (z: Complex, w: Complex) -> Bool {
return z.x == w.x && z.y == w.y
}
func Re(a: Complex) -> Double {
return a.x
}
func Im(a: Complex) -> Double {
let z = 2 + 3 * i
こういう風に書ける
z
let z = 2 + 3 * iz
{
Complex(0, 1) 定数として定義してある
こういう風に書ける
let z = 2 + 3 * i
こういう風に書ける
{
Complex(3, 0) * Complex(0, 1)
z
{
Complex(0, 1)
let z = 2 + 3 * i
こういう風に書ける
{
Complex(3, 0) * Complex(0, 1)
{
z
{
Complex(0, 1)
Complex(2, 0) + Complex(3, 0) * Complex(0, 1)
let z = 2 + 3 * i
こういう風に書ける
{
Complex(3, 0) * Complex(0, 1)
{
Complex(2, 0) + Complex(3, 0) * Complex(0, 1)
z
let z: Complex = Complex(2, 0) + Complex(3, 0) * Complex(0, 1)
{
{
Complex(0, 1)
i * i == -1
i * i == -1
{
Complex(0, 1) * Complex(0, 1)
i * i == -1
{
Complex(0, 1) * Complex(0, 1)
{
Complex(0, 1) * Complex(0, 1) == Complex(1, 0)
いい感じだ!
let r = 2.0
let θ = M_PI / 4
let z = r * (cos(θ) + i * cos(θ))
let r = 2.0
let θ = M_PI / 4
let z = r * (cos(θ) + i * cos(θ))
!?
let i = Complex(0, 1)
let a = -1
i * i == a
let i = Complex(0, 1)
let a = -1
i * i == a
…???
import Foundation
struct Complex: Equatable, IntegerLiteralConvertible, FloatLiteralConvertible {
let x: Double
let y: Double
init(_ x: Double, _ y: Double) {
self.x = x
self.y = y
}
init(_ x: Double) {
self.x = x
self.y = 0
}
init(integerLiteral x: IntegerLiteralType) {
self.x = Double(x)
self.y = 0
}
init(floatLiteral x: FloatLiteralType) {
self.x = x
self.y = 0
}
init(r: Double, θ: Double) {
self.x = r * cos(θ)
self.y = r * sin(θ)
}
}
func == (z: Complex, w: Complex) -> Bool {
return z.x == w.x && z.y == w.y
}
func Re(a: Complex) -> Double {
return a.x
}
func Im(a: Complex) -> Double {
IntegerLiteralConvertible, FloatLiteralConvertible
IntegerLiteralConvertible, FloatLiteralConvertible
IntegerLiteralConvertible, FloatLiteralConvertible
リテラルからしか暗黙的キャストできない…
残念だが仕方ない。
xxxLiteralConvertible
• ArrayLiteralConvertible
• BooleanLiteralConvertible
• DictionaryLiteralConvertible
• FloatLiteralConvertible
• NilLiteralConvertible
• IntegerLiteralConvertible
• StringLiteralConvertible
• UnicodeScalarLiteralConvertible
struct Matrix3x3<T>: ArrayLiteralConvertible {
init(arrayLiteral elements: T...) {
// ...
}
}
let m: Matrix3x3 = [1, 0, 0,
0, 1, 0,
0, 0, 1];
これぐらいのことはできる
さらに残念なことに、
let url: NSURL = “http://yahoo.co.jp”
let image: UIImage = “image.png"
let color: UIColor = 0x722F37
let url: NSURL = “http://yahoo.co.jp”
let image: UIImage = “image.png"
let color: UIColor = 0x722F37
↑ Swift 1.0 でできてたのが、1.1 でできなくなった…
本当に残念。
Thanks...
Twitter: taketo1024
Blog: http://taketo1024.hateblo.jp/

Weitere ähnliche Inhalte

Was ist angesagt?

2.7 chain rule short cuts
2.7 chain rule short cuts2.7 chain rule short cuts
2.7 chain rule short cuts
math265
 
Complex form fourier series
Complex form fourier seriesComplex form fourier series
Complex form fourier series
derry92
 
2.2 limits ii
2.2 limits ii2.2 limits ii
2.2 limits ii
math265
 
4.1 inverse functions
4.1 inverse functions4.1 inverse functions
4.1 inverse functions
math260
 
09 - Program verification
09 - Program verification09 - Program verification
09 - Program verification
Tudor Girba
 

Was ist angesagt? (20)

Inverse functions
Inverse functionsInverse functions
Inverse functions
 
2.7 chain rule short cuts
2.7 chain rule short cuts2.7 chain rule short cuts
2.7 chain rule short cuts
 
Lesson 8: Derivatives of Polynomials and Exponential functions
Lesson 8: Derivatives of Polynomials and Exponential functionsLesson 8: Derivatives of Polynomials and Exponential functions
Lesson 8: Derivatives of Polynomials and Exponential functions
 
하스켈 프로그래밍 입문 3
하스켈 프로그래밍 입문 3하스켈 프로그래밍 입문 3
하스켈 프로그래밍 입문 3
 
Jacobians new
Jacobians newJacobians new
Jacobians new
 
functions limits and continuity
functions limits and continuityfunctions limits and continuity
functions limits and continuity
 
Complex form fourier series
Complex form fourier seriesComplex form fourier series
Complex form fourier series
 
하스켈 프로그래밍 입문 4
하스켈 프로그래밍 입문 4하스켈 프로그래밍 입문 4
하스켈 프로그래밍 입문 4
 
Truth, deduction, computation lecture g
Truth, deduction, computation   lecture gTruth, deduction, computation   lecture g
Truth, deduction, computation lecture g
 
Partial Derivatives
Partial DerivativesPartial Derivatives
Partial Derivatives
 
2.2 limits ii
2.2 limits ii2.2 limits ii
2.2 limits ii
 
Integral calculus
Integral calculusIntegral calculus
Integral calculus
 
Lesson 10: The Chain Rule
Lesson 10: The Chain RuleLesson 10: The Chain Rule
Lesson 10: The Chain Rule
 
4.1 inverse functions
4.1 inverse functions4.1 inverse functions
4.1 inverse functions
 
09 - Program verification
09 - Program verification09 - Program verification
09 - Program verification
 
Fourier series 1
Fourier series 1Fourier series 1
Fourier series 1
 
Lesson 11: The Chain Rule
Lesson 11: The Chain RuleLesson 11: The Chain Rule
Lesson 11: The Chain Rule
 
Digital Electronics
Digital ElectronicsDigital Electronics
Digital Electronics
 
Inverse functions
Inverse functionsInverse functions
Inverse functions
 
Inverse functions
Inverse functionsInverse functions
Inverse functions
 

Andere mochten auch

Rexhep qosja te vertetat e vonuara
Rexhep qosja   te vertetat e vonuaraRexhep qosja   te vertetat e vonuara
Rexhep qosja te vertetat e vonuara
Libra Islame
 
「数える」とは何か? 〜 「とは何か?」を問う、AI時代の数学
「数える」とは何か? 〜 「とは何か?」を問う、AI時代の数学「数える」とは何か? 〜 「とは何か?」を問う、AI時代の数学
「数える」とは何か? 〜 「とは何か?」を問う、AI時代の数学
Taketo Sano
 

Andere mochten auch (20)

プログラマのための線形代数再入門
プログラマのための線形代数再入門プログラマのための線形代数再入門
プログラマのための線形代数再入門
 
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
 
基礎からのベイズ統計学 輪読会資料 第8章 「比率・相関・信頼性」
基礎からのベイズ統計学 輪読会資料  第8章 「比率・相関・信頼性」基礎からのベイズ統計学 輪読会資料  第8章 「比率・相関・信頼性」
基礎からのベイズ統計学 輪読会資料 第8章 「比率・相関・信頼性」
 
objc2swift (自動変換の野望)
objc2swift (自動変換の野望)objc2swift (自動変換の野望)
objc2swift (自動変換の野望)
 
「ベータ分布の謎に迫る」第6回 プログラマのための数学勉強会 LT資料
「ベータ分布の謎に迫る」第6回 プログラマのための数学勉強会 LT資料「ベータ分布の謎に迫る」第6回 プログラマのための数学勉強会 LT資料
「ベータ分布の謎に迫る」第6回 プログラマのための数学勉強会 LT資料
 
let UIWebView as WKWebView
let UIWebView as WKWebViewlet UIWebView as WKWebView
let UIWebView as WKWebView
 
「全ての確率はコイン投げに通ず」 Japan.R 発表資料
「全ての確率はコイン投げに通ず」 Japan.R 発表資料「全ての確率はコイン投げに通ず」 Japan.R 発表資料
「全ての確率はコイン投げに通ず」 Japan.R 発表資料
 
objc2swift (続・自動変換の野望)
objc2swift (続・自動変換の野望) objc2swift (続・自動変換の野望)
objc2swift (続・自動変換の野望)
 
Rexhep qosja te vertetat e vonuara
Rexhep qosja   te vertetat e vonuaraRexhep qosja   te vertetat e vonuara
Rexhep qosja te vertetat e vonuara
 
Partial least squares回帰と画像認識への応用
Partial least squares回帰と画像認識への応用Partial least squares回帰と画像認識への応用
Partial least squares回帰と画像認識への応用
 
基礎からのベイズ統計学 輪読会資料 第4章 メトロポリス・ヘイスティングス法
基礎からのベイズ統計学 輪読会資料 第4章 メトロポリス・ヘイスティングス法基礎からのベイズ統計学 輪読会資料 第4章 メトロポリス・ヘイスティングス法
基礎からのベイズ統計学 輪読会資料 第4章 メトロポリス・ヘイスティングス法
 
DS LT祭り 「AUCが0.01改善したって どういうことですか?」
DS LT祭り 「AUCが0.01改善したって どういうことですか?」DS LT祭り 「AUCが0.01改善したって どういうことですか?」
DS LT祭り 「AUCが0.01改善したって どういうことですか?」
 
「数える」とは何か? 〜 「とは何か?」を問う、AI時代の数学
「数える」とは何か? 〜 「とは何か?」を問う、AI時代の数学「数える」とは何か? 〜 「とは何か?」を問う、AI時代の数学
「数える」とは何か? 〜 「とは何か?」を問う、AI時代の数学
 
統計的学習の基礎 4章 前半
統計的学習の基礎 4章 前半統計的学習の基礎 4章 前半
統計的学習の基礎 4章 前半
 
objc2swift 〜 Objective-C から Swift への「コード&パラダイム」シフト
objc2swift 〜 Objective-C から Swift への「コード&パラダイム」シフトobjc2swift 〜 Objective-C から Swift への「コード&パラダイム」シフト
objc2swift 〜 Objective-C から Swift への「コード&パラダイム」シフト
 
基底変換、固有値・固有ベクトル、そしてその先
基底変換、固有値・固有ベクトル、そしてその先基底変換、固有値・固有ベクトル、そしてその先
基底変換、固有値・固有ベクトル、そしてその先
 
異常検知と変化検知 第4章 近傍法による異常検知
異常検知と変化検知 第4章 近傍法による異常検知異常検知と変化検知 第4章 近傍法による異常検知
異常検知と変化検知 第4章 近傍法による異常検知
 
「深層学習」勉強会LT資料 "Chainer使ってみた"
「深層学習」勉強会LT資料 "Chainer使ってみた"「深層学習」勉強会LT資料 "Chainer使ってみた"
「深層学習」勉強会LT資料 "Chainer使ってみた"
 
プログラマのための線形代数再入門2 〜 要件定義から学ぶ行列式と逆行列
プログラマのための線形代数再入門2 〜 要件定義から学ぶ行列式と逆行列プログラマのための線形代数再入門2 〜 要件定義から学ぶ行列式と逆行列
プログラマのための線形代数再入門2 〜 要件定義から学ぶ行列式と逆行列
 
Random Forest による分類
Random Forest による分類Random Forest による分類
Random Forest による分類
 

Ähnlich wie 2015 02-18 xxx-literalconvertible

Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meet
Mario Fusco
 
I am trying to create a program That works with two other programs i.pdf
I am trying to create a program That works with two other programs i.pdfI am trying to create a program That works with two other programs i.pdf
I am trying to create a program That works with two other programs i.pdf
fortmdu
 
Functional programming basics
Functional programming basicsFunctional programming basics
Functional programming basics
openbala
 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdf
info30292
 

Ähnlich wie 2015 02-18 xxx-literalconvertible (20)

Generics and Inference
Generics and InferenceGenerics and Inference
Generics and Inference
 
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
 
Operator Overloading In Scala
Operator Overloading In ScalaOperator Overloading In Scala
Operator Overloading In Scala
 
Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meet
 
I am trying to create a program That works with two other programs i.pdf
I am trying to create a program That works with two other programs i.pdfI am trying to create a program That works with two other programs i.pdf
I am trying to create a program That works with two other programs i.pdf
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFrom Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf Milan
 
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
 
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
 
Kotlin collections
Kotlin collectionsKotlin collections
Kotlin collections
 
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...The Functional Programming Triad of Folding, Scanning and Iteration - a first...
The Functional Programming Triad of Folding, Scanning and Iteration - a first...
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Functional programming basics
Functional programming basicsFunctional programming basics
Functional programming basics
 
Chap 2 Arrays and Structures.ppt
Chap 2  Arrays and Structures.pptChap 2  Arrays and Structures.ppt
Chap 2 Arrays and Structures.ppt
 
Chap 2 Arrays and Structures.pptx
Chap 2  Arrays and Structures.pptxChap 2  Arrays and Structures.pptx
Chap 2 Arrays and Structures.pptx
 
Swift 함수 커링 사용하기
Swift 함수 커링 사용하기Swift 함수 커링 사용하기
Swift 함수 커링 사용하기
 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdf
 
Idioms in swift 2016 05c
Idioms in swift 2016 05cIdioms in swift 2016 05c
Idioms in swift 2016 05c
 
Pragmatic metaprogramming
Pragmatic metaprogrammingPragmatic metaprogramming
Pragmatic metaprogramming
 
Lezione03
Lezione03Lezione03
Lezione03
 

Mehr von Taketo Sano

Divisibility of Lee’s class and its relation with Rasmussen’s invariant / 201...
Divisibility of Lee’s class and its relation with Rasmussen’s invariant / 201...Divisibility of Lee’s class and its relation with Rasmussen’s invariant / 201...
Divisibility of Lee’s class and its relation with Rasmussen’s invariant / 201...
Taketo Sano
 
Swift で数学のススメ 〜 プログラミングと数学は同時に学べ
Swift で数学のススメ 〜 プログラミングと数学は同時に学べSwift で数学のススメ 〜 プログラミングと数学は同時に学べ
Swift で数学のススメ 〜 プログラミングと数学は同時に学べ
Taketo Sano
 
山手線は丸いのか?プログラマのためのトポロジー入門
山手線は丸いのか?プログラマのためのトポロジー入門山手線は丸いのか?プログラマのためのトポロジー入門
山手線は丸いのか?プログラマのためのトポロジー入門
Taketo Sano
 
何もないところから数を作る
何もないところから数を作る何もないところから数を作る
何もないところから数を作る
Taketo Sano
 
虚数は作れる!Swift で学ぶ複素数
虚数は作れる!Swift で学ぶ複素数虚数は作れる!Swift で学ぶ複素数
虚数は作れる!Swift で学ぶ複素数
Taketo Sano
 
ひろ子 in Objective-C
ひろ子 in Objective-Cひろ子 in Objective-C
ひろ子 in Objective-C
Taketo Sano
 
Konashi で始める iOS 電子工作
Konashi で始める iOS 電子工作Konashi で始める iOS 電子工作
Konashi で始める iOS 電子工作
Taketo Sano
 

Mehr von Taketo Sano (18)

Divisibility of Lee’s class and its relation with Rasmussen’s invariant / 201...
Divisibility of Lee’s class and its relation with Rasmussen’s invariant / 201...Divisibility of Lee’s class and its relation with Rasmussen’s invariant / 201...
Divisibility of Lee’s class and its relation with Rasmussen’s invariant / 201...
 
トポロジーと圏論の夜明け
トポロジーと圏論の夜明けトポロジーと圏論の夜明け
トポロジーと圏論の夜明け
 
Swift で数学研究のススメ
Swift で数学研究のススメSwift で数学研究のススメ
Swift で数学研究のススメ
 
(意欲的な中高生のための)トポロジー・圏論・コンピュータ
(意欲的な中高生のための)トポロジー・圏論・コンピュータ(意欲的な中高生のための)トポロジー・圏論・コンピュータ
(意欲的な中高生のための)トポロジー・圏論・コンピュータ
 
特性類の気持ち
特性類の気持ち特性類の気持ち
特性類の気持ち
 
Swift で数学のススメ 〜 プログラミングと数学は同時に学べ
Swift で数学のススメ 〜 プログラミングと数学は同時に学べSwift で数学のススメ 〜 プログラミングと数学は同時に学べ
Swift で数学のススメ 〜 プログラミングと数学は同時に学べ
 
山手線は丸いのか?プログラマのためのトポロジー入門
山手線は丸いのか?プログラマのためのトポロジー入門山手線は丸いのか?プログラマのためのトポロジー入門
山手線は丸いのか?プログラマのためのトポロジー入門
 
何もないところから数を作る
何もないところから数を作る何もないところから数を作る
何もないところから数を作る
 
情報幾何学 #2.4
情報幾何学 #2.4情報幾何学 #2.4
情報幾何学 #2.4
 
情報幾何学 #2 #infogeo16
情報幾何学 #2 #infogeo16情報幾何学 #2 #infogeo16
情報幾何学 #2 #infogeo16
 
何もないところから数を作る
何もないところから数を作る何もないところから数を作る
何もないところから数を作る
 
さらに上を目指すための iOS アプリ設計
さらに上を目指すための iOS アプリ設計さらに上を目指すための iOS アプリ設計
さらに上を目指すための iOS アプリ設計
 
コードを書けば複素数がわかる
コードを書けば複素数がわかるコードを書けば複素数がわかる
コードを書けば複素数がわかる
 
虚数は作れる!Swift で学ぶ複素数
虚数は作れる!Swift で学ぶ複素数虚数は作れる!Swift で学ぶ複素数
虚数は作れる!Swift で学ぶ複素数
 
ひろ子 in Objective-C
ひろ子 in Objective-Cひろ子 in Objective-C
ひろ子 in Objective-C
 
Objective-C が好きになる Tips & Hack
Objective-C が好きになる Tips & HackObjective-C が好きになる Tips & Hack
Objective-C が好きになる Tips & Hack
 
Konashi で始める iOS 電子工作
Konashi で始める iOS 電子工作Konashi で始める iOS 電子工作
Konashi で始める iOS 電子工作
 
下位互換コード隠蔽のストイシズム
下位互換コード隠蔽のストイシズム下位互換コード隠蔽のストイシズム
下位互換コード隠蔽のストイシズム
 

Kürzlich hochgeladen

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+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
 
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
VictoriaMetrics
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Kürzlich hochgeladen (20)

%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
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
 
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
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+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...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
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
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 

2015 02-18 xxx-literalconvertible

  • 2.
  • 4. 2014/10/18 「iOS 8 / Swift 勉強会 @ ヤフー」
  • 5. import Foundation struct Complex: Equatable, IntegerLiteralConvertible, FloatLiteralConvertible { let x: Double let y: Double init(_ x: Double, _ y: Double) { self.x = x self.y = y } init(_ x: Double) { self.x = x self.y = 0 } init(integerLiteral x: IntegerLiteralType) { self.x = Double(x) self.y = 0 } init(floatLiteral x: FloatLiteralType) { self.x = x self.y = 0 } init(r: Double, θ: Double) { self.x = r * cos(θ) self.y = r * sin(θ) } } func == (z: Complex, w: Complex) -> Bool { return z.x == w.x && z.y == w.y } func Re(a: Complex) -> Double { return a.x } func Im(a: Complex) -> Double {
  • 6. import Foundation struct Complex: Equatable, IntegerLiteralConvertible, FloatLiteralConvertible { let x: Double let y: Double init(_ x: Double, _ y: Double) { self.x = x self.y = y } init(_ x: Double) { self.x = x self.y = 0 } init(integerLiteral x: IntegerLiteralType) { self.x = Double(x) self.y = 0 } init(floatLiteral x: FloatLiteralType) { self.x = x self.y = 0 } init(r: Double, θ: Double) { self.x = r * cos(θ) self.y = r * sin(θ) } } func == (z: Complex, w: Complex) -> Bool { return z.x == w.x && z.y == w.y } func Re(a: Complex) -> Double { return a.x } func Im(a: Complex) -> Double {
  • 7. import Foundation struct Complex: Equatable, IntegerLiteralConvertible, FloatLiteralConvertible { let x: Double let y: Double init(_ x: Double, _ y: Double) { self.x = x self.y = y } init(_ x: Double) { self.x = x self.y = 0 } init(integerLiteral x: IntegerLiteralType) { self.x = Double(x) self.y = 0 } init(floatLiteral x: FloatLiteralType) { self.x = x self.y = 0 } init(r: Double, θ: Double) { self.x = r * cos(θ) self.y = r * sin(θ) } } func == (z: Complex, w: Complex) -> Bool { return z.x == w.x && z.y == w.y } func Re(a: Complex) -> Double { return a.x } func Im(a: Complex) -> Double {
  • 8. let z = 2 + 3 * i こういう風に書ける z
  • 9. let z = 2 + 3 * iz { Complex(0, 1) 定数として定義してある こういう風に書ける
  • 10. let z = 2 + 3 * i こういう風に書ける { Complex(3, 0) * Complex(0, 1) z { Complex(0, 1)
  • 11. let z = 2 + 3 * i こういう風に書ける { Complex(3, 0) * Complex(0, 1) { z { Complex(0, 1) Complex(2, 0) + Complex(3, 0) * Complex(0, 1)
  • 12. let z = 2 + 3 * i こういう風に書ける { Complex(3, 0) * Complex(0, 1) { Complex(2, 0) + Complex(3, 0) * Complex(0, 1) z let z: Complex = Complex(2, 0) + Complex(3, 0) * Complex(0, 1) { { Complex(0, 1)
  • 13. i * i == -1
  • 14. i * i == -1 { Complex(0, 1) * Complex(0, 1)
  • 15. i * i == -1 { Complex(0, 1) * Complex(0, 1) { Complex(0, 1) * Complex(0, 1) == Complex(1, 0)
  • 17. let r = 2.0 let θ = M_PI / 4 let z = r * (cos(θ) + i * cos(θ))
  • 18. let r = 2.0 let θ = M_PI / 4 let z = r * (cos(θ) + i * cos(θ)) !?
  • 19. let i = Complex(0, 1) let a = -1 i * i == a
  • 20. let i = Complex(0, 1) let a = -1 i * i == a …???
  • 21. import Foundation struct Complex: Equatable, IntegerLiteralConvertible, FloatLiteralConvertible { let x: Double let y: Double init(_ x: Double, _ y: Double) { self.x = x self.y = y } init(_ x: Double) { self.x = x self.y = 0 } init(integerLiteral x: IntegerLiteralType) { self.x = Double(x) self.y = 0 } init(floatLiteral x: FloatLiteralType) { self.x = x self.y = 0 } init(r: Double, θ: Double) { self.x = r * cos(θ) self.y = r * sin(θ) } } func == (z: Complex, w: Complex) -> Bool { return z.x == w.x && z.y == w.y } func Re(a: Complex) -> Double { return a.x } func Im(a: Complex) -> Double {
  • 26. xxxLiteralConvertible • ArrayLiteralConvertible • BooleanLiteralConvertible • DictionaryLiteralConvertible • FloatLiteralConvertible • NilLiteralConvertible • IntegerLiteralConvertible • StringLiteralConvertible • UnicodeScalarLiteralConvertible
  • 27. struct Matrix3x3<T>: ArrayLiteralConvertible { init(arrayLiteral elements: T...) { // ... } } let m: Matrix3x3 = [1, 0, 0, 0, 1, 0, 0, 0, 1]; これぐらいのことはできる
  • 29. let url: NSURL = “http://yahoo.co.jp” let image: UIImage = “image.png" let color: UIColor = 0x722F37
  • 30. let url: NSURL = “http://yahoo.co.jp” let image: UIImage = “image.png" let color: UIColor = 0x722F37 ↑ Swift 1.0 でできてたのが、1.1 でできなくなった…