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
38
Pythonを書いていておーマジかーと感じたあれこれ
kunou
1
730
ネットワークグラフを作成する
kunou
0
54
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
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.5k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
It's Worth the Effort
3n
184
28k
Product Roadmaps are Hard
iamctodd
PRO
53
11k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Bash Introduction
62gerente
614
210k
The Pragmatic Product Professional
lauravandoore
35
6.7k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
6
670
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
137
34k
Adopting Sorbet at Scale
ufuk
76
9.4k
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の方が百倍よく使うけど……) •他にも面白い使い方があったら 教えてください