Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discrepancy between mapCLR_ and mapR_. #11

Closed
yotamDvir opened this issue Aug 11, 2018 · 0 comments
Closed

Discrepancy between mapCLR_ and mapR_. #11

yotamDvir opened this issue Aug 11, 2018 · 0 comments
Labels

Comments

@yotamDvir
Copy link
Owner

See example below. For readability, list notation with center denoted by *s is used for a pivot.

mapR_ (List.take 1) [1,2,*3*,4,5] == [1,2,*3*,5]
mapCLR_ identity identity (List.take 1) [1,2,*3*,4,5] == [1,2,*3*,4]

Awkward implementation and lack of testing are to blame.

elm-pivot/Pivot/Map.elm

Lines 70 to 73 in cee1b98

mapR_ : (List a -> List a) -> Pivot a -> Pivot a
mapR_ f =
mapL_ f
|> mirror

Documentation makes matters worse, as it hints that these two applications above should have the same result.

elm-pivot/Pivot.elm

Lines 530 to 532 in cee1b98

{-| See `mapCLR_`.
-}
mapR_ : (List a -> List a) -> Pivot a -> Pivot a

As for fixing, the following works:

mapR_ = mapCLR_ identity identity

Still, it could be optimized, as mapCLR_ internally reverses the left side twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant