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

add add-lens, subtract-lens, and modulo-lens #289

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlexKnauth
Copy link
Collaborator

I still need to provide it from unstable/lens and add it to the unstable docs.

> (lens-view (add-lens 5) 3)
8
> (lens-set (add-lens 5) 3 8)
3
> (lens-set (add-lens 5) 3 27)
22
> (lens-view (modulo-lens 10) 2)
2
> (lens-set (modulo-lens 10) 2 8)
8
> (lens-view (modulo-lens 10) 23)
3
> (lens-set (modulo-lens 10) 23 9)
29

Resolves #288

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 98.937% when pulling de41ec0 on AlexKnauth:data-number into 11ecc2f on jackfirth:master.

@jackfirth
Copy link
Owner

add-lens and subtract-lens don't seem as useful, since they're just isomorphisms that don't do any destructuring.

This has me thinking about #205 again. Since that issue was last discussed, I've run into cases where I want just isomorphisms and don't care about lenses. As we add more utility isomorphisms like add and subtract, there will be more use in having isomorphisms separate.

@AlexKnauth
Copy link
Collaborator Author

AlexKnauth commented Sep 21, 2016

I just ran into a situation where a multiply-lens (for non-zero scalar inputs) would be useful. I wanted a round-to-the-nearest-thousandth function and I wanted

(define round-to-the-nearest-thousandth (lens-transform (multiply-lens 1000) _ exact-round))

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

Successfully merging this pull request may close these issues.

Modulo lens
3 participants