タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

javascriptとtransducerに関するmanabouのブックマーク (1)

  • JavaScript: transducerを作ってみた

    transducerというものがあるというのを知って、どんなものか自分でもやってみた。 関数合成が見やすく効率的にできるそうな。 試行錯誤の結果、こうなりました。 const compose = (...fs) => x => fs.reduceRight( (acc, f) => f(acc), x ) const mapping = f => reducing => (acc, e) => reducing(acc, f(e)) const filtering = f => reducing => (acc, e) => f(e) ? reducing(acc, e) : reducing(acc, undefined) const folding = f => x => reducing => (acc, e) => acc.length === 0 ? reducing(acc,

    JavaScript: transducerを作ってみた
  • 1