deleteWith function & friends

未關閉
#242 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
35/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
停滯
領域
backend

研究方向

The issue provides a deleteWith example and links to purescript/purescript-arrays#167; no source files or tests are named. Read that linked issue and the array library’s existing findIndex and delete functions to understand the available APIs. Done means deciding which “with” functions belong in the library and implementing and testing the agreed set.

由索引模型根據 Issue 內容生成。

描述

A lot of functions like delete require an index. A lot of times that index was not stored (which would also get updated as the array would change) but has to be refound with findIndex. When you use findIndex and immediately after use delete you know you are guaranteed an index that is not out of bounds. Could "with" functions be added that do this?

deleteWith :: forall a. (a -> Boolean) -> Array a -> Maybe (Array a)
deleteWith pred array = map (\idx -> unsafeDeleteAt idx array) (findIndex pred array)

It would make sense to have the unsafe implementations for them available, at least internally in the array library https://github.com/purescript/purescript-arrays/issues/167

One could argue that if you do this you are better off using a Map. But i think people will want to use an array plenty of times anyway.

主要語言
PureScript
星號
58
分支
70
平均合併
2 天 22 小時
30 天內合併 PR
1

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 有 Pull Request 範本
  • 沒有貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

purescript/purescript-arrays 的其他 Issue

查看 purescript/purescript-arrays 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。