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
671671-- | Transforms a list of pairs into a list of first components and a list of
672672-- | second components.
673673unzip :: 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'
676685
677686-- | Perform a fold using a monadic step function.
678687foldM :: 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