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
520
Make Mouse
kunou
0
640
RubyのProcのあれをこうしました
kunou
0
99
esm lt Clojure like threading macro
kunou
0
440
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1031
460k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.4k
Site-Speed That Sticks
csswizardry
10
690
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
We Have a Design System, Now What?
morganepeng
53
7.7k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.4k
How STYLIGHT went responsive
nonsquared
100
5.6k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.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の方が百倍よく使うけど……) •他にも面白い使い方があったら 教えてください