調べた事
Js
- Transducers: Efficient Data Processing Pipelines in JavaScript@Eric Elliott -Medium
- Understanding Transducers in JavaScript@Roman Liutikov -Medium
半分位から、特によく分からなくなった記事
- What's a Transducer?
- Simpler Transducers for JavaScript
- How to make your data transformations more efficient using transducers
Clojure
Clojureは公式ページのチュートリアル2ページほど読み、基礎構文初歩は理解しました(CommonLispの基礎部分を以前少しやっており理解できました)。transducerの例に出てくるライブラリの関数等は、逐次調べ、例題コードの理解率は75%ほどです、多分。。
質問
以下の理解・jsコードが合っている・間違っている のかを知りたいです。ご教授宜しくお願い致します<(_ _)>????
Transducerとは
compose()して返却された関数構成群がtransducerである。- transducerを実行するには、❶
transduce()に渡す以外にも、❷transducer()に配列を渡す事でも実行できる。 - ❷の内部処理において、中間値が生成されるような処理ではなく、下画像のような効率的な処理がなされる。

via:画像ソース元 Understanding Transducers in JavaScript@Roman Liutikov -Medium
自分で書いたコード
js
1"use strict"; 2 3const map = fn => arr => arr.map(fn), 4filter = fn => arr => arr.filter(fn), 5addReducer = arr => arr.reduce((acc, num) => acc + num, 0), 6add1 = n => n + 1, 7even = n => n % 2 === 0, 8 9compose = (...fns) => initVal => fns.reduce((acc, fn) => fn(acc), initVal), 10transduce = (xform, reducer, arr ) => reducer( xform(arr) ); 11 12 13 14const arr = [1,2,3], 15transducer = compose( // transducer もしくは xform と呼ぶ 16 map( add1 ), // 2,3,4 17 filter( even ), // 2,4 18); 19 20console.log( transducer(arr) ) // 2,4 21console.log( transduce(transducer, addReducer, arr) ) // 6
https://stackoverflow.com/questions/56507025/is-my-understanding-and-js-code-about-transducer-correct
Multipost???
yes. the question in different language and different services is illegal?At that time, I stronglly want to undersnad teansducer, so I post the question about tenasducer in Stackoverflow.en and teratail.
You should read the following link carefully.
https://teratail.com/help#posted-otherservice
I think teratail does NOT recommend to post the question to multi site regardless language and country.
Oh, I remembered you are a multi accounter in teratail.
So, this is like a talking to the wall for immoralist like you.
Sorry for bother you.
Please forget about it.
Thank. But..., those help page mentioned that it is not RECOMMENDED to multiposting, but not stated that it is prohibited. In addition, the help page is not stated about different language.
In my opitnion, the reason why multiposting is bad practice is that it makes web viewer confused and ruin web resources. So, I think multiposting in different language is not a problem.
yeah, I understand that this is my personal opinion. So I will send inquiry to the dev team of teratail and take action following these response.
Grateful to comment to know me for those information. I haven't read those page.
Sincerely.
Please give me a chance short time! That action is testing purpose to answering the quiestion and not abusing pupose. So, I suddenly delete that account. If you doubt me, please search that account(azumax) in serach form in teratail's navigation bar.
https://teratail.com/questions/194413#reply-289205
回答2件
あなたの回答
tips
プレビュー