Add zipper exercise - #223
Merged
Merged
Conversation
Member
This is not cheating, since Exercism is not a testing platform. This is a learning platform, and asking for help is definitely not cheating. |
Contributor
|
Is this ready to merge @ageron? I am mainly wondering if it's feasible for exercism students to find the elegant solution or if it will mostly be frustrating :p |
Contributor
Author
|
Thanks for reviewing, @anton. Yes, I believe it's ready to merge: it's difficult but doable, and we don't have that many difficult exercises, so I think it's ok. |
Anton-4
approved these changes
Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the Zipper exercise.
Note: The solution (
.meta/Example.roc) contains a really uglyupfunction. I couldn't find a better way to implement it because it doesn't seem possible to easily add a default field to a record (see this Zulip discussion: #beginners > Cannot add fields to a record with default fields). That said, this is just an example solution, the stub (Tree.roc) remains reasonably elegant.Note 2: I pondered whether I should provide the definition of the
Zippertype. I chose to leave it out because thinking about how you might design a zipper is half the fun. My original solution was horrible, so I eventually cheated and asked an AI how zippers are typically implemented for trees. Coming up with something and then learning about something better was a much better learning experience than simply being handed the best design from the start. Once you know the design, implementing it isn't too difficult.Note 3: in my solution, the
Crumbtype is currently:Once the discussion about adding default fields to records is resolved, it will probably be better to implement it as: