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
| package main | |
| import ( | |
| "fmt" | |
| "math/rand" | |
| "sort" | |
| "time" | |
| ) |
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
| func reduce<T,R>(list: [T], block: (([R],T) -> R?)) -> [R]? { | |
| var acc = [R]() | |
| for x in list { | |
| if let val = block(acc, x) { | |
| acc += [val] | |
| } | |
| } | |
| return acc | |
| } |
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
| #coding:utf-8 | |
| #Xcode上の不要なファイルを抽出するスクリプト | |
| puts "- start class file #{Time.now.strftime("%Y/%m/%d %H:%M:%S")}" | |
| class_waste_count = 0 | |
| #クラスファイルの一覧を取得 | |
| result = `find ~/SampleProject -type f -name "*.h" -exec basename {} \\; | sort` | |
| class_filenames = result.split("\n") |
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
| -- 1. リストを引数に取って、length に π (=3.1415)を返す関数 | |
| pieTime x = fromIntegral (length x) + (pi :: Float) | |
| -- 2. 2つの文字列を引数にとって、数値として足し算する関数 | |
| addString x y = (read x::Int) + (read y::Int) | |
| -- 3. 文字列を逆する関数 | |
| reverse' x = [x !! z | z <- [((length x) - 1), ((length x) - 2)..0]] | |
| -- 4. 文字列が回文かどうかを判定する関数 isPalindrome |
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 displayLink = CADisplayLink(target: self, selector: Selector("update:")) | |
| displayLink.addToRunLoop(NSRunLoop.currentRunLoop(), forMode: NSRunLoopCommonModes) |
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
| void objc_setAssociatedObject(id object, const void *key, id value, objc_AssociationPolicy policy) | |
| // id object: プロパティを持たせたいオブジェクト | |
| // void *key: プロパティのアドレス (static で宣言した不変なローカルな静的変数を指定する) | |
| // id value: 保持させるのオブジェクト | |
| // objc_AssociationPolicy policy: 関連付けの方法 (後述) |
NewerOlder