Skip to content

Add transpose to Data.Array #226

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 3 commits into from
Jul 28, 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
Prev Previous commit
Improve layout of doc comments
  • Loading branch information
newlandsvalley committed Jul 27, 2022
commit 9735c956d530951c62c32e138522fa05b8aa1c3f
19 changes: 17 additions & 2 deletions src/Data/Array.purs
Original file line number Diff line number Diff line change
Expand Up @@ -786,13 +786,28 @@ intercalate = F.intercalate
-- | For example,
-- |
-- | ```purescript
-- | transpose [[1,2,3], [4,5,6]] == [[1,4], [2,5], [3,6]]
-- | transpose
-- | [ [1, 2, 3]
-- | , [4, 5, 6]
-- | ] ==
-- | [ [1, 4]
-- | , [2, 5]
-- | , [3, 6]
-- | ]
-- | ```
-- |
-- | If some of the rows are shorter than the following rows, their elements are skipped:
-- |
-- | ```purescript
-- | transpose [[10,11], [20], [30,31,32]] == [[10,20,30], [11,31], [32]]
-- | transpose
-- | [ [10, 11]
-- | , [20]
-- | , [30, 31, 32]
-- | ] ==
-- | [ [10, 20, 30]
-- | , [11, 31]
-- | , [32]
-- | ]
-- | ```
transpose :: forall a. Array (Array a) -> Array (Array a)
transpose xs = go 0 []
Expand Down