Skip to content

Is there scope for a fold function? #55

@NeilW

Description

@NeilW

I'm noticing I'm doing a lot of

(a -> b -> b) -> b -> Maybe a -> b

when manipulating a couple of arrays. I'll get a value from array1 which is a Maybe value, and then apply it to array2 if it exists.

My code has lots of

case Array.get index1 array1 of
    Just value -> 
        Array.set index2 value array2

    Nothing -> 
        array2

given that's a signature for a fold, is it worth adding it? Which would give

Array.get index1 array1
|> Maybe.Extra.foldl (Array.set index2) array2 

Metadata

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