Skip to content

JaggedCollection.transpose results in wrong result when applied to rows of varying length #319

Closed
@bvenn

Description

Transpose operations as in JaggedArray.transpose and JaggedList.transpose should be applied to collections of equal length. When collections exist, that are longer than the first one, they get truncated:

let a = [|
	[|1; 2; 3|]
	[|1; 2; 3; 4|]
	|]

JaggedArray.transpose a
//[| [|1; 1|]; [|2; 2|]; [|3; 3|]|]

When the first element is the longest, an error is thrown:

let a2 = [|
	[|1; 2; 3; 4|]
	[|1; 2; 3|]
	|]

JaggedArray.transpose a2
//throws: System.IndexOutOfRangeException: Index was outside the bounds of the array.

The following additions should be made

  • add XML documentation that describes the requirements
  • add checks that all collections are of the same size
  • add unchecked transpose_ versions, that work as before

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions