Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Make findMin and findMax tail-recursive #121

@no-longer-on-githu-b

Description

@no-longer-on-githu-b

These functions can be easily made tail-recursive.

findMax :: forall k v. Map k v -> Maybe { key :: k, value :: v }
findMax = go Nothing
  where
  go acc Leaf = acc
  go _   (Two _ k1 v1 right) = go (Just { key: k1, value: v1 }) right
  go _   (Three _ _ _ _ k2 v2 right) = go (Just { key: k2, value: v2 }) right

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