-
Notifications
You must be signed in to change notification settings - Fork 0
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
PYP 2021 q4c #585
Comments
Are you able to show the question for part c? |
You can try putting these tests into your shell and see if both results yield true; if yes, then its a functor, else no. |
@Zhenyubbx edited to include part c! |
I checked with my TA, I think the Box class doesn't seem to obey both Functor requirements The easiest counter example is from the identity law Box.of("cs2030").map(x -> x).equals(Box.of("cs2030")); The code above yields false since map function will return new Box object, therefore it is not a functor |
@calvinseptyanto Thanks alot calvin! That clears up a bit for me |
Hi I think I can offer an alternative counterexample that might be more specific to this Box implementation as it has to do with the toUpperCase part
CMIIW thanks! |
Sick hehe, may i know what are your f1 and f2 functions hehe |
f1 and f2 are shown in the lines above the one you quoted. But I believe you can also test with any dummy functions that could modify the string, eg. substring, string concatenation, toUpper/LowerCase, just as a proof of concept. |
Source
AY 20/21 q4c


Description
Hi everyone Im having issues with justifying question 4c. I know there 2 laws/criteria in being a functor. But the s.toUpperCase() throws me off abit. Does that affect it being a functor? and If not, is there anything that proves that it is not a functor
Screenshots (if any):
Insert Images here if necessary
The text was updated successfully, but these errors were encountered: