Recommended
PDF
PDF
モダン PHP テクニック 12 選 ―PsalmとPHP 8.1で今はこんなこともできる!―
PDF
PPTX
PDF
PHP-FPM の子プロセス制御方法と設定をおさらいしよう
PDF
WebRTC と Native とそれから、それから。
PDF
Freer Monads, More Extensible Effects
PDF
PDF
PDF
PDF
PDF
PDF
Reconnaissance of Virtio: What’s new and how it’s all connected?
PDF
PDF
PPL 2022 招待講演: 静的型つき函数型組版処理システムSATySFiの紹介
PDF
ARM CPUにおけるSIMDを用いた高速計算入門
PPTX
PDF
PDF
Intro to SVE 富岳のA64FXを触ってみた
PDF
PDF
組み込み関数(intrinsic)によるSIMD入門
PDF
"Simple Made Easy" Made Easy
PDF
PDF
C#次世代非同期処理概観 - Task vs Reactive Extensions
PPTX
PostgreSQLクエリ実行の基礎知識 ~Explainを読み解こう~
PPTX
PPTX
PDF
C/C++とWebAssemblyを利用したライブラリ開発
KEY
Clojure + MongoDB on Heroku
PDF
Clojureシンタックスハイライター開発から考えるこれからのlispに必要なもの
More Related Content
PDF
PDF
モダン PHP テクニック 12 選 ―PsalmとPHP 8.1で今はこんなこともできる!―
PDF
PPTX
PDF
PHP-FPM の子プロセス制御方法と設定をおさらいしよう
PDF
WebRTC と Native とそれから、それから。
PDF
Freer Monads, More Extensible Effects
PDF
What's hot
PDF
PDF
PDF
PDF
PDF
Reconnaissance of Virtio: What’s new and how it’s all connected?
PDF
PDF
PPL 2022 招待講演: 静的型つき函数型組版処理システムSATySFiの紹介
PDF
ARM CPUにおけるSIMDを用いた高速計算入門
PPTX
PDF
PDF
Intro to SVE 富岳のA64FXを触ってみた
PDF
PDF
組み込み関数(intrinsic)によるSIMD入門
PDF
"Simple Made Easy" Made Easy
PDF
PDF
C#次世代非同期処理概観 - Task vs Reactive Extensions
PPTX
PostgreSQLクエリ実行の基礎知識 ~Explainを読み解こう~
PPTX
PPTX
PDF
C/C++とWebAssemblyを利用したライブラリ開発
Viewers also liked
KEY
Clojure + MongoDB on Heroku
PDF
Clojureシンタックスハイライター開発から考えるこれからのlispに必要なもの
PDF
『はじめてのClojure』勉強会#3 第7章:テスト、テスト、テスト
KEY
PDF
PDF
Clojure Language Update (2015)
PDF
PDF
渋谷JVM#1 Immutable時代のプログラミング言語 Clojure
PDF
プログラミング言語Clojureのニャンパスでの活用事例
PDF
PDF
ZIP
Semiotika: Nastroj pro lepsi uzivatelsky prozitek?
PPT
Selling UX with Daniel Szuc
PDF
Jan Wilhelm Koelnmesse - Address Quality as a pre-requisite for centralised i...
PDF
How to get ready for the fast future - #CCHUC15
PPS
PPT
Monosílabos, interrogativos y exclamativos
PDF
【第17回八子クラウド座談会 LT】CloudConductor+VDCのご紹介
PDF
40 proven social media marketing tips for seafood industry
DOCX
Conjugate the following verbs in the present tense
Similar to 入門Transducers
KEY
Clojure programming-chapter-2
PDF
PDF
PDF
PDF
PDF
Introduction to Categorical Programming
PPTX
PDF
PPTX
ODP
PDF
PDF
ODP
PPT
KEY
PDF
Introduction to Categorical Programming (Revised)
PDF
Adding simpl GVN path into GHC
KEY
Algebraic DP: 動的計画法を書きやすく
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.