Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ZIP!!
Search
kunou
July 13, 2017
0
180
ZIP!!
kunou
July 13, 2017
Tweet
Share
More Decks by kunou
See All by kunou
GANについて
kunou
0
440
AIか何かについて.pdf
kunou
0
39
Pythonを書いていておーマジかーと感じたあれこれ
kunou
1
730
ネットワークグラフを作成する
kunou
0
58
Rubyで機械学習してみた
kunou
1
1.1k
zip
kunou
0
510
Make Mouse
kunou
0
640
RubyのProcのあれをこうしました
kunou
0
99
esm lt Clojure like threading macro
kunou
0
440
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Raft: Consensus for Rubyists
vanstee
140
7k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.8k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
930
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
The Pragmatic Product Professional
lauravandoore
35
6.7k
Scaling GitHub
holman
459
140k
Code Review Best Practice
trishagee
68
18k
Building Applications with DynamoDB
mza
95
6.5k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Transcript
I❤zip (car (cdr ϑΝϯΫγϣϯ۞ָ෦)) 12.07.2017
I❤zip kunou@esm •ࣾͷษڧձͰ ClojureΛॻ͍ͯ·͢ •ࠓͷHaskell Λ֮͑Δ͜ͱͩͬͨ ʢաڈܗʣ
I❤zip ͖ͳؔ zip
I❤zip ͖ͳؔ zip 当然ながらこれの話ではありません ☓
I❤zip ͖ͳؔ zip (zip [1 2 3] [4 5 6])
=> ((1 4) (2 5) (3 6))
I❤zip ͖ͳؔ zip でもClojureにはzipがない…… (zipmapはあるけど)
I❤zip ͖ͳؔ zip でもClojureにはzipがない…… (zipmapはあるけど) (defn zip [a b] (map
list a b))
I❤zip zipのよくある使い方 普通に使う (zip [1 2 3] [4 5 6])
=> ((1 4) (2 5) (3 6))
I❤zip zipのよくある使い方 indexを付ける Clojureならmap-indexedを使えと言う話は置いておいて (zip (iterate inc 0) [:a :b
:c :d :e]) => ((0 :a) (1 :b) (2 :c) (3 :d) (4 :e))
I❤zip zipのちょっと変わった使い方
I❤zip zipのちょっと変わった使い方 (def days [ (t/date-time 2017 7 7) (t/date-time
2017 7 8) (t/date-time 2017 7 9) (t/date-time 2017 7 11) (t/date-time 2017 7 13)]) こんな感じのvectorがあるとき…… ※clj-time Λ༻
I❤zip zipのちょっと変わった使い方 (def days [ (t/date-time 2017 7 7) (t/date-time
2017 7 8) (t/date-time 2017 7 9) (t/date-time 2017 7 11) (t/date-time 2017 7 13)]) こんな感じのvectorがあるとき……空いて いる日付が欲しい
I❤zip zipのちょっと変わった使い方 (def days [ (t/date-time 2017 7 7) (t/date-time
2017 7 8) (t/date-time 2017 7 9) (t/date-time 2017 7 11) (t/date-time 2017 7 13)]) こんな感じのvectorがあるとき……空いて いる日付が欲しい
I❤zip zipのちょっと変わった使い方 (zip days (rest days))
I❤zip zipのちょっと変わった使い方 (zip days (rest days)) => ((2017-07-07 2017-07-08) (2017-07-08
2017-07-09) (2017-07-09 2017-07-11) (2017-07-11 2017-07-13))
I❤zip zipのちょっと変わった使い方 (->> (zip days (rest days)) (remove #(let [[x
y] %] (= (+ (t/day x) 1) (t/day y)))) (map first) (map #(t/plus % (t/days 1))))
I❤zip zipのちょっと変わった使い方 (->> (zip days (rest days)) (remove #(let [[x
y] %] (= (+ (t/day x) 1) (t/day y)))) (map first) (map #(t/plus % (t/days 1)))) => ((2017-07-07 2017-07-08) (2017-07-08 2017-07-09) (2017-07-09 2017-07-11) (2017-07-11 2017-07-13))
I❤zip zipのちょっと変わった使い方 (->> (zip days (rest days)) (remove #(let [[x
y] %] (= (+ (t/day x) 1) (t/day y)))) (map first) (map #(t/plus % (t/days 1)))) => ((2017-07-09 2017-07-11) (2017-07-11 2017-07-13))
I❤zip zipのちょっと変わった使い方 (->> (zip days (rest days)) (remove #(let [[x
y] %] (= (+ (t/day x) 1) (t/day y)))) (map first) (map #(t/plus % (t/days 1)))) => ((2017-07-09) (2017-07-11))
I❤zip zipのちょっと変わった使い方 (->> (zip days (rest days)) (remove #(let [[x
y] %] (= (+ (t/day x) 1) (t/day y)))) (map first) (map #(t/plus % (t/days 1)))) => ((2017-07-10) (2017-07-12))
I❤zip zipのちょっと変わった使い方 (->> (zip days (rest days)) (remove #(let [[x
y] %] (= (+ (t/day x) 1) (t/day y)))) (map first) (map #(t/plus % (t/days 1)))) => ((2017-07-10) (2017-07-12))
I❤zip まとめ
I❤zip まとめ •zip便利
I❤zip まとめ •zip便利 (map, reduceの方が百倍よく使うけど……)
I❤zip まとめ •zip便利 (map, reduceの方が百倍よく使うけど……) •他にも面白い使い方があったら 教えてください