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
430
AIか何かについて.pdf
kunou
0
34
Pythonを書いていておーマジかーと感じたあれこれ
kunou
1
720
ネットワークグラフを作成する
kunou
0
52
Rubyで機械学習してみた
kunou
1
1.1k
zip
kunou
0
510
Make Mouse
kunou
0
640
RubyのProcのあれをこうしました
kunou
0
97
esm lt Clojure like threading macro
kunou
0
430
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.3k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Building Adaptive Systems
keathley
41
2.5k
Gamification - CAS2011
davidbonilla
81
5.2k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
Rails Girls Zürich Keynote
gr2m
94
13k
Why Our Code Smells
bkeepers
PRO
336
57k
We Have a Design System, Now What?
morganepeng
51
7.5k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
30
1.1k
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の方が百倍よく使うけど……) •他にも面白い使い方があったら 教えてください