Skip to content

Make Relude.List.permutations return a NonEmpty. #385

@kindaro

Description

@kindaro

You may observe that any list has at least one permutation. The empty list's only permutation is the empty list itself, so:

λ Relude.List.permutations [ ]
[[]]

This behaviour is also theoretically sound since permutations of a list are a model of a symmetric group and a group always has at least one element.

It is nicer to have to drop from a NonEmpty to a list than to lift from a list to NonEmpty, since the latter requires the handling of the spurious case of the list being empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    newBring something new into library (add function or type or interface)questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions