Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[API Proposal]: Extend the reduce and reduceBack to Collections

オープン
#625 コメント 41 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
fsharp

調査の方向性

まず、既存のreduce関数の実装と、41件のコメントがある議論を読み、未解決のAPI上の懸念を理解します。提案されているreduceおよびreduceBackのシグネチャを、list、array、seqのネイティブ操作と比較します。完了条件は、汎用コレクションと空の入力時の動作を対象とする、合意済みの設計と概念実証です。

索引モデルが issue の本文から書いたものです。

説明

Background and motivation

From the requirements point of view: the fold function must provide init, reduce does not require init, which means no longer needs to write boilerplate "match with" code like "extract the first element from generic Collections as init, the remaining elements as sequence, and then pass it to fold".

From a reasonable point of view: list/array/seq all provide native reduce methods, list/array also provides native reduceBack methods. This generic encapsulation is not difficult to implement, and other languages ​​(except fundamental FPs like Haskell) generally provide reduce methods, which is reasonable.

I know there is a reduce function implementation now, but that one is very difficult to use. To be honest, I have no idea how to pass parameters.

API Proposal
let inline reduce (folder: 'State->'T->'State) (foldable: '``Foldable<'T>``) : 'State

let inline reduceBack (folder: 'T->'State->'State) (foldable: '``Foldable<'T>``) : 'State
API Usage
reduce (*) [1; 2; 3; 4; 5] |> should equal 120
reduce (+) ([]: int list) // throws an exception
Alternative Designs

No response

Risks

No response

Are you willing to help with a proof-of-concept (as PR in that or a separate repo) first and as pull-request later on?

Yes, please assign this issue to me.

主要言語
F#
スター
942
フォーク
105
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fsprojects/FSharpPlus のほかの issue

fsprojects/FSharpPlus の issue をすべて見る

似ている issue

DevTools の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。