Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Functions for identity and equality checking #147

@msoeken

Description

@msoeken

Is your feature request related to a problem? Please describe.
I find myself writing these functions when making use of the array iteration functions such as Mapped and Filtered.

Describe the solution you'd like
I suggest to have functions in the library for Identity<'T>(a), EqualsX(a, b), NotEqualsX(a, b), where X in I, B, D, and L.

Here is an example how these functions can be used for retrieving all bits in an integer that are 1 in their binary expansion:

function IntegerBits(val : Int, bits : Int) : Int[] {
    let id = Id<(Int, Bool)>;
    let pred = Compose(EqualsB(_, true), Snd<Int, Bool>);
    return Mapped(Fst<Int, Bool>, Filtered(pred, MappedByIndex(id, IntAsBoolArray(val, bits))));
}

Describe alternatives you've considered
Writing the functions as local private functions.

Additional context
N/A

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions