Getting Started With Ore-Ore Swift Standard Library +Tomohiro Kumagai
?
Swift Open Source を自分でビルドするとっかかり的なところをざっくりまとめた資料です。環境づくり(ソフト的)と、ビルド方法と、ちょっと遊んでみる方法と、そして再び環境づくり(ハード的)、そんなお話。
2017/04/22 の第72回 Cocoa 勉強会関西と 2017.04.28 の Swift 愛好会 Vol8 で発表したものになります。
Ruby on Railsを使った開発イメージをRuby on Railsを触ったことがないデベロッパー向けに発表しましたので、公開します。
*発表時より、Railsを使った実際の構成例を紹介するスライドを追加しています。
このイベントです。
https://general.connpass.com/event/63492/
1. Yuichi Yoshida
Chief engineer, DENSO IT Laboratory, Inc.
@sonson_twit
? 2014 DENSO IT Laboratory, Inc., All rights reserved. Redistribution or public display not permitted without written permission from DENSO IT Laboratory, Inc.
Value type programmingの話もしたい
Programming Swift 2 (& LLDB) シンポジウム
foldrをとにかく速くする
17. 普通のreverseっぽい
extension SequenceType {
/// Return an `Array` containing the elements of `self` in reverse
/// order.
///
/// Complexity: O(N), where N is the length of `self`.
@warn_unused_result
public func reverse() -> [Self.Generator.Element]
}
18. 発見!O(1)とか書いてる
extension CollectionType where Index : BidirectionalIndexType {
/// Return the elements of `self` in reverse order.
///
/// - Complexity: O(1)
@warn_unused_result
public func reverse() -> ReverseCollection<Self>
}
extension CollectionType where Index : RandomAccessIndexType {
/// Return the elements of `self` in reverse order.
///
/// - Complexity: O(1)
@warn_unused_result
public func reverse() -> ReverseRandomAccessCollection<Self>
}
19. ReverseCollection
/// A Collection that presents the elements of its `Base` collection
/// in reverse order.
///
/// - Note: This type is the result of `x.reverse()` where `x` is a
/// collection having bidirectional indices.
///
/// The `reverse()` method is always lazy when applied to a collection
/// with bidirectional indices, but does not implicitly confer
/// laziness on algorithms applied to its result. In other words, for
/// ordinary collections `c` having bidirectional indices:
///
/// * `c.reverse()` does not create new storage
/// * `c.reverse().map(f)` maps eagerly and returns a new array
/// * `c.lazy.reverse().map(f)` maps lazily and returns a `LazyMapCollection`
///
/// - See also: `ReverseRandomAccessCollection`
20. ReverseRandomAccessCollection
/// A Collection that presents the elements of its `Base` collection
/// in reverse order.
///
/// - Note: This type is the result of `x.reverse()` where `x` is a
/// collection having random access indices.
/// - See also: `ReverseCollection`
21. この型にだけextensionを実装してみる
extension CollectionType where Index : RandomAccessIndexType {
func foldr_loop2<T>(accm:T, @noescape f: (Self.Generator.Element, T) -> T) -> T {
var result = accm
for temp in self.reverse() {
result = f(temp, result)
}
return result
}
func foldr_reduce2<T>(accm:T, @noescape f: (T, Self.Generator.Element) -> T) -> T {
return self.reverse().reduce(accm) { f($0, $1) }
}
func foldr_forEach2<T>(accm:T, @noescape f: (Self.Generator.Element, T) -> T) -> T {
var result = accm
self.reverse().forEach { (t) -> () in
result = f(t, result)
}
return result
}
}