andre-dietrich/elm-conditional/1.0.0

Conditional.List

A set of conditional functions for maipulating Lists.

Create

addIf : 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 : 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 : Bool -> (a -> a) -> List a -> List a

Conditional application of a mapping function.

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

Conditional application of a filtering.

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

Conditional application of a filterMap function.

Utilities

reverseIf : Bool -> List a -> List a

Conditional list reverse.

Combine

appendIf : 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 : Bool -> (a -> List a) -> List a -> List a

Conditional concatMap.

intersperseIf : Bool -> a -> List a -> List a

Conditional application of intersperse.

Sort

sortIf : Bool -> List comparable -> List comparable

Conditional sort.

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

Conditional sortBy.

Deconstruct

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

Conditional application of List.take.

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

Conditional application of List.drop.