Instructions for Zipper exercise are misleading.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- javascript
- Ambito
- documentation
Direzione di ricerca
Inizia con le istruzioni e la suite di test dell'esercizio Zipper del track JavaScript, quindi confronta la loro descrizione di uno Zipper con i riferimenti collegati di Wikipedia e Wikibooks. Decidi se l'esercizio debba chiarire il modello funzionale, aggiungere test per alberi immutabili e lo stato di Zipper, oppure essere rinominato, quindi aggiorna la documentazione o i test pertinenti in modo che il comportamento previsto sia inequivocabile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi,
Issue:
I don't know if this is the right place to report this but I found the instructions for Zipper on the Javascript track to be misleading.
The instructions say "Zippers are a purely functional way of navigating within a data structure and manipulating it. They essentially contain a data structure and a pointer into that data structure (called the focus)."
In a purely functional setting, the data structure is immutable. The pointer into the data structure could read from inside the structure, but it couldn't modify it in any way. The only way to set a new value is to build new structure with the modified value based on the old data.
The linked Wikipedia page says of list-zippers: "Consequently, a list-zipper is a pair consisting of both the location as a context or starting point, and a recording or path that permits reconstruction from that starting location." And the reference that Wikipedia uses says (in a mythological setting about exploring a labyrinth): "The zipper is a pair of Ariadne's thread and the current sub-labyrinth that the player stands on top."
The point being the Zipper does not contain the full data structure and a pointer. It is two things:
- The steps (thread) leading up to the focused node (Did I go left or right here? What was the value of the node here? What was the other subtree?)
- The rest of the structure, from the focused node down (In this case the subtree starting at the focused node).
From these two things, you can rebuild the full structure, including making modifications by creating new subtrees with modified values as you reverse the steps.
Now, I managed to implement a Zipper according to the description on Wikipedia but I am not sure it makes sense to do this in Javascript. As the Wikipedia says, "In a non-purely-functional programming language, it may be more convenient to simply traverse the original data structure and modify it directly (perhaps after deep cloning it, to avoid affecting other code that might hold a reference to it)." But doing this is not a Zipper.
Potential Solutions:
-
Update problem statement to better reflect what a Zipper is. (Recorded thread + rest of structure)
-
Modify the test suite: If we still want a Zipper in Javascript, then the test suite needs to be more detailed. First, the input tree should be frozen/immutable. It should check that all output is also immutable and all intermediate stages do not have side effects (i.e a new Zipper with a new thread and a new tree is created at every stage).
-
Add guiding tests: Have tests that check what the current thread is in the Zipper after running different methods and what the current subtree is. E.g. if zipper is
Zipper.fromTree(bt(1, bt(2, null, leaf(3)), leaf(4))), the Zipper returned by zipper.left() will have subtreebt(2, null, leaf(3))and thread will be something like[{direction: "left", value: 1, otherSubtree: leaf(4)}]This will make the exercise much easier, since the nature of what a Zipper is will be clear. You may not want to do this though since the problem is specified as Hard; a suitable description on the problem page may be sufficient. -
Change the problem to making a copy of the tree and maintaining a pointer into the tree. The problem would need a different name and couldn't refer to the Zipper data structure.
Anyway, I haven't contributed here before so I don't know what the procedure is for this sort of thing. Also I'm not particularly familiar with Javascript so there might be better solutions than my suggestions above. Please let me know your thoughts and if I should do anything.
Thanks,
Josh
- Lingua principale
- JavaScript
- Stelle
- 652
- Fork
- 658
- Merge medio
- 13h 46m
- PR unite (30g)
- 6
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di exercism/javascript
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
exercism/javascript#2865 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
exercism/javascript#2847 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
exercism/javascript#2832 ·
-
exercism/javascript#2310 · 22 commenti · 1 assegnatario ·
-
pinned :pushpin:
Difficoltà 5/5 Più di una settimana Idoneità per principianti 5/100
exercism/javascript#2144 ·
Tutte le issue di exercism/javascript
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
mksglu/context-mode#1200 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
neondatabase/website#5944 ·
-
module: core
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
bigbluebutton/bigbluebutton#25849 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
jaegertracing/jaeger-ui#4506 ·