andre-dietrich / elm-conditional / Conditional.List

A set of conditional functions for maipulating Lists.

Create

addIf : Basics.Bool -> a -> List a -> List a

Add an element to the front of a List only if the first condition is parameter evaluates to True.

addWhen : Maybe a -> List a -> List a

Add an element to the front of a List only if the value is not Nothing

attachIf : Basics.Bool -> a -> List a -> List a

Add an element to the end of a List, if the first parameter evalutes to True.

attachWhen : Maybe a -> List a -> List a

Add an element to the end of a List, if the element is not Nothing.

Transform

mapIf : Basics.Bool -> (a -> a) -> List a -> List a

Conditional application of a mapping function.

filterIf : Basics.Bool -> (a -> Basics.Bool) -> List a -> List a

Conditional application of a filtering.

filterMapIf : Basics.Bool -> (a -> Maybe a) -> List a -> List a

Conditional application of a filterMap function.

Utilities

reverseIf : Basics.Bool -> List a -> List a

Conditional list reverse.

Combine

appendIf : Basics.Bool -> List a -> List a -> List a

Perform a List.append only if the first condition is met, otherwise the second List defines the result.

appendWhen : Maybe (List a) -> List a -> List a

Perform a List.append only if the first parameter is not Nothing.

concatMapIf : Basics.Bool -> (a -> List a) -> List a -> List a

Conditional concatMap.

intersperseIf : Basics.Bool -> a -> List a -> List a

Conditional application of intersperse.

Sort

sortIf : Basics.Bool -> List comparable -> List comparable

Conditional sort.

sortByIf : Basics.Bool -> (a -> comparable) -> List a -> List a

Conditional sortBy.

Deconstruct

takeIf : Basics.Bool -> Basics.Int -> List a -> List a

Conditional application of List.take.

dropIf : Basics.Bool -> Basics.Int -> List a -> List a

Conditional application of List.drop.