def curry[A, B, C, D](f: (A, B, C) => D): A => B => C => D = ???
def uncurry[A, B, C, D](f: A => B => C => D): (A, B, C) => D = ???
def compose[A, B, C, D](f: A => B, g: B => C, h: C => D): A => D = ???
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let disposeBag = DisposeBag() | |
let scheduler = SerialDispatchQueueScheduler(globalConcurrentQueuePriority: .Default) | |
[1,2,3,4,5].asObservable() | |
.observeOn(scheduler) | |
.subscribeNext({ (num) -> Void in | |
NSLog("background: \(num)") | |
}) | |
.addDisposableTo(disposeBag) | |
NSLog("main") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let disposeBag = DisposeBag() | |
let scheduler = OperationQueueScheduler(operationQueue: NSOperationQueue()) | |
[1,2,3,4,5].asObservable() | |
.observeOn(scheduler) | |
.subscribeNext({ (num) -> Void in | |
NSLog("background: \(num)") | |
}) | |
.addDisposableTo(disposeBag) | |
NSLog("main") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data BTree a = BLeaf | BNode (BTree a) (BTree a) | |
count :: BTree a -> Integer | |
count BLeaf = 1 | |
count (BNode l r) = count l + count r | |
foldTree f z BLeaf = z | |
foldTree f z (BNode l r) = f (foldTree f z l) (foldTree f z r) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 二分木が平衡状態であるという事を,各節点で 3(m + 1) ≧ n + 1 かつ 3(n + 1) ≧ m + 1 が成り立つ事とします。(n,mは左右の部分木の節点数) | |
-- 二分木が平衡状態か否かを判定する関数を相互再帰定理に基いて導出して下さい。 | |
-- https://gist.github.com/eldesh/5970931 | |
data Tree a = Leaf a | Node (Tree a) a (Tree a) deriving(Show, Eq) | |
instance Foldable Tree where | |
foldr f z (Leaf x) = f x z | |
foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* [ ] ご注文はうさぎですか?? アドベントカレンダー | |
* [ ] エンジニアハッカソン向け企画内容 | |
* [ ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* [ ] iOS開発におけるDI | |
* [ ] Logging | |
* [ ] 設定ファイルのもち方・切り替え | |
* [ ] Mockライブラリ | |
* [ ] | |
(注)この記事はScala関数型プログラミング&デザイン7章前半の劣化版まとめです
整数列の足し算について考えてみよう。たたみ込みなどがパッと思い付くだろう。
def sum(ints: Seq[Int]): Int = ints.foldLeft(0)((a, b) => a + b)
// 注: scalaでは整数列のたたみ込み演算についてあらかじめ関数が用意されていて、
// IntelliJを使っている場合は上記のコードに対して以下のsum関数を用いることを勧められるかもしれない
// at scala.TraversableOnce