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
170
ZIP!!
kunou
July 13, 2017
Tweet
Share
More Decks by kunou
See All by kunou
GANについて
kunou
0
420
AIか何かについて.pdf
kunou
0
30
Pythonを書いていておーマジかーと感じたあれこれ
kunou
1
720
ネットワークグラフを作成する
kunou
0
47
Rubyで機械学習してみた
kunou
1
1.1k
zip
kunou
0
500
Make Mouse
kunou
0
630
RubyのProcのあれをこうしました
kunou
0
92
esm lt Clojure like threading macro
kunou
0
420
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Building Your Own Lightsaber
phodgson
103
6.1k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
For a Future-Friendly Web
brad_frost
175
9.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
Agile that works and the tools we love
rasmusluckow
327
21k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
89
How GitHub (no longer) Works
holman
310
140k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Into the Great Unknown - MozCon
thekraken
32
1.5k
How to train your dragon (web standard)
notwaldorf
88
5.7k
A designer walks into a library…
pauljervisheath
203
24k
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の方が百倍よく使うけど……) •他にも面白い使い方があったら 教えてください