Elm
import List exposing (all, sum) import Maybe exposing (andThen, map) isAngle : Int -> Bool isAngle angle = angle > 0 && angle < 180 maybeAngles : List Int -> Maybe (List Int) maybeAngles angles = if all isAngle angles && sum angles < 180 then Just angles else Nothing third : Int -> Int -> Maybe Int third first second = maybeAngles [ first, second ] |> map (sum >> (-) 180)
Test it online
Here.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Elm
Test it online
Here.