Recommended
PDF
Spectacular Future with clojure.spec
PPTX
ネットストーカー御用達OSINTツールBlackBirdを触ってみた.pptx
PDF
macOSの仮想化技術について ~Virtualization-rs Rust bindings for virtualization.framework ~
PDF
PDF
PDF
MagicOnion~C#でゲームサーバを開発しよう~
PDF
JVMパラメータチューニングにおけるOptunaの活用事例 ( Optuna Meetup #1 )
PPTX
RLSを用いたマルチテナント実装 for Django
PDF
「GraphDB徹底入門」〜構造や仕組み理解から使いどころ・種々のGraphDBの比較まで幅広く〜
PDF
PDF
PDF
SQLアンチパターン 幻の第26章「とりあえず削除フラグ」
PPTX
世界一わかりやすいClean Architecture
PDF
最近のKaggleに学ぶテーブルデータの特徴量エンジニアリング
PDF
PDF
PDF
GoらしいAPIを求める旅路 (Go Conference 2018 Spring)
PDF
PDF
PDF
PDF
PDF
PPTX
9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...
PDF
[Cloud OnAir] BigQuery の仕組みからベストプラクティスまでのご紹介 2018年9月6日 放送
PDF
Pythonはどうやってlen関数で長さを手にいれているの?
PDF
Docker入門-基礎編 いまから始めるDocker管理【2nd Edition】
PDF
Webアプリを並行開発する際のマイグレーション戦略
PDF
PDF
プログラミング言語Clojureのニャンパスでの活用事例
PPT
Monosílabos, interrogativos y exclamativos
More Related Content
PDF
Spectacular Future with clojure.spec
PPTX
ネットストーカー御用達OSINTツールBlackBirdを触ってみた.pptx
PDF
macOSの仮想化技術について ~Virtualization-rs Rust bindings for virtualization.framework ~
PDF
PDF
PDF
MagicOnion~C#でゲームサーバを開発しよう~
PDF
JVMパラメータチューニングにおけるOptunaの活用事例 ( Optuna Meetup #1 )
PPTX
RLSを用いたマルチテナント実装 for Django
What's hot
PDF
「GraphDB徹底入門」〜構造や仕組み理解から使いどころ・種々のGraphDBの比較まで幅広く〜
PDF
PDF
PDF
SQLアンチパターン 幻の第26章「とりあえず削除フラグ」
PPTX
世界一わかりやすいClean Architecture
PDF
最近のKaggleに学ぶテーブルデータの特徴量エンジニアリング
PDF
PDF
PDF
GoらしいAPIを求める旅路 (Go Conference 2018 Spring)
PDF
PDF
PDF
PDF
PDF
PPTX
9/14にリリースされたばかりの新LTS版Java 17、ここ3年間のJavaの変化を知ろう!(Open Source Conference 2021 O...
PDF
[Cloud OnAir] BigQuery の仕組みからベストプラクティスまでのご紹介 2018年9月6日 放送
PDF
Pythonはどうやってlen関数で長さを手にいれているの?
PDF
Docker入門-基礎編 いまから始めるDocker管理【2nd Edition】
PDF
Webアプリを並行開発する際のマイグレーション戦略
PDF
Viewers also liked
PDF
プログラミング言語Clojureのニャンパスでの活用事例
PPT
Monosílabos, interrogativos y exclamativos
PDF
Jan Wilhelm Koelnmesse - Address Quality as a pre-requisite for centralised i...
KEY
PDF
KEY
Clojure + MongoDB on Heroku
PDF
渋谷JVM#1 Immutable時代のプログラミング言語 Clojure
PDF
PDF
Clojureシンタックスハイライター開発から考えるこれからのlispに必要なもの
DOCX
Conjugate the following verbs in the present tense
PDF
Clojure Language Update (2015)
ZIP
Semiotika: Nastroj pro lepsi uzivatelsky prozitek?
PDF
『はじめてのClojure』勉強会#3 第7章:テスト、テスト、テスト
PDF
40 proven social media marketing tips for seafood industry
PDF
PPT
Selling UX with Daniel Szuc
PDF
【第17回八子クラウド座談会 LT】CloudConductor+VDCのご紹介
PDF
How to get ready for the fast future - #CCHUC15
PPS
PDF
Similar to 入門Transducers
PDF
PDF
PDF
PDF
KEY
Algebraic DP: 動的計画法を書きやすく
PDF
PDF
Introduction to Categorical Programming
ODP
PDF
KEY
PPT
PDF
Introduction to Categorical Programming (Revised)
PPTX
ODP
PPTX
KEY
Clojure programming-chapter-2
PDF
Adding simpl GVN path into GHC
PDF
PDF
PDF
More from sohta
PDF
PDF
PDF
PDF
genuine-highlighter: マクロを認識するClojure向けのシンタックスハイライター
PDF
PDF
PDF
入門Transducers 1. 2. 3. Transducers are composable algorithmic transformations.
They are independent from the context of their input and
output sources and specify only the essence of the
transformation in terms of an individual element. Because
transducers are decoupled from input or output sources,
they can be used in many different processes - collections,
streams, channels, observables, etc.
http://clojure.org/transducers
4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 0 1 2 3 4
51 2 3 4
(range 5)
(map inc)
inc inc inc inc inc
18. 0 1 2 3 4
51 2 3 4
51 3
(range 5)
(map inc)
(filter odd?)
inc inc inc inc inc
odd? odd? odd? odd? odd?
19. 0 1 2 3 4
51 2 3 4
51 3
(range 5)
(map inc)
(filter odd?)
9
inc inc inc inc inc
odd? odd? odd? odd? odd?
(reduce + 0)
++ +
20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. (reduce + 0 (map inc s))
「各要素を1足して、
先頭から順に要素を足し合わせる」
(reduce (fn [a x] (+ a (inc x))) 0 s)
「先頭から順に各要素に1足した値を足し合わせる」
これは以下と等価
33. 34. 35. 36. 37. 38. 39. 40. (reduce + 0 (filter odd? s))
「奇数以外の要素を取り除き、
先頭から順に要素を足し合わせる」
41. (reduce + 0 (filter odd? s))
「奇数以外の要素を取り除き、
先頭から順に要素を足し合わせる」
(reduce (fn [a x]
(if (odd? x) (+ a x) a))
0 s)
「先頭から順に奇数の要素を足し合わせる」
これは以下と等価
42. 43. (reduce (fn [a x]
(if (odd? x) (+ a x) a))
0 s)
(fn [a x]
(if (odd? x) (+ a x) a))
44. 45. 46. 47. 48. 49. 50. 52. 53. 54. 0
要素に1足して処理
奇数ならば処理
1 2 3 4
Reducible
Reducible = Transducer + コレクション
逆に、Transducerとは
Reducibleからコレクションへの依存を除き
汎用的に使えるようにしたものといえる
55. 56. 57. Transducerを引数にとるAPI
(transduce xf f init s)
= (reduce (xf f) init s)
(into to xf from)
コレクションfromをtransducerで変換しながらコレ
クションtoに変換
(eduction xf coll)
transducerとコレクションからReducibleを生成
58. 59.