Skip to content

Use FunctorWithIndex.mapWithIndex #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 23, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use FunctorWithIndex.mapWithIndex
  • Loading branch information
JordanMartinez committed Aug 22, 2022
commit 15494d09deef3c056816963d537ee26580f8f51c
4 changes: 2 additions & 2 deletions src/Data/Array.purs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ import Data.Array.ST as STA
import Data.Array.ST.Iterator as STAI
import Data.Foldable (class Foldable, traverse_)
import Data.Foldable as F
import Data.FunctorWithIndex as FWI
import Data.Maybe (Maybe(..), maybe, isJust, fromJust, isNothing)
import Data.Traversable (sequence, traverse)
import Data.Tuple (Tuple(..), fst, snd)
Expand Down Expand Up @@ -738,8 +739,7 @@ catMaybes = mapMaybe identity
-- | ```
-- |
mapWithIndex :: forall a b. (Int -> a -> b) -> Array a -> Array b
mapWithIndex f xs =
zipWith f (range 0 (length xs - 1)) xs
mapWithIndex = FWI.mapWithIndex

-- | Change the elements at the specified indices in index/value pairs.
-- | Out-of-bounds indices will have no effect.
Expand Down