File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -671,8 +671,17 @@ zip = zipWith Tuple
671
671
-- | Transforms a list of pairs into a list of first components and a list of
672
672
-- | second components.
673
673
unzip :: forall a b . Array (Tuple a b ) -> Tuple (Array a ) (Array b )
674
- unzip = uncons' (\_ -> Tuple [] [] ) \(Tuple a b) ts -> case unzip ts of
675
- Tuple as bs -> Tuple (a : as) (b : bs)
674
+ unzip xs =
675
+ pureST do
676
+ fsts <- emptySTArray
677
+ snds <- emptySTArray
678
+ iter <- iterator (xs !! _)
679
+ iterate iter \(Tuple fst snd) -> do
680
+ void $ pushSTArray fsts fst
681
+ void $ pushSTArray snds snd
682
+ fsts' <- unsafeFreeze fsts
683
+ snds' <- unsafeFreeze snds
684
+ pure $ Tuple fsts' snds'
676
685
677
686
-- | Perform a fold using a monadic step function.
678
687
foldM :: forall m a b . Monad m => (a -> b -> m a ) -> a -> Array b -> m a
You can’t perform that action at this time.
0 commit comments