-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
implement linked-list exercise #372
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @voila, and thanks for your PR on this one, too.
The reason I haven't responded is that I am torn on it:
In a pure functional language, a doubly-linked list is not that interesting. The idea of a doubly linked list is to be able to grab a node and go in either direction, or to be able to splice into the middle of a list. In a pure functionaly language you probably are better off with one of these two data structures:
A singly linked list with a pointer in the middle, from which you can go either left or right (a variant of Huet's "Zipper")
A finger tree, which is a mind-blowing data structure invented by Ralf Hinze and Ross Paterson.
I'm a big fan of the zipper; it's useful in a lot of situations.
Note that there is already a zipper exercise. We currently don't have any exercises that address finger trees; do you think this could be more interesting, perhaps?
https://www.youtube.com/watch?v=UXdr_K0Lwg4
https://en.wikipedia.org/wiki/Finger_tree
OCaml is not a purely functional language. I think it's interesting to see imperative stuff done with it too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, then. Let's add the exercise.
The following comment relates to the problem-specifications repo and not this exercise. I'm noting that the following property of the exercise is rather unnecessary:
To keep your implementation simple, the tests will not cover error
conditions. Specifically: `pop` or `shift` will never be called on an
empty list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, there was one line that needs to be changed.
Hi @voila, and sorry for post-poning this review for so long. I'll look at it tomorrow morning! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so I felt bad about having neglected this PR until now and made an assessment now instead.
Besides the individual comments made, I have one observation: It seems that the tests are manually made, which is fine by me. But it also happens that @marionebl made a pretty significant (but perhaps still somewhat undocumented--yet to be confirmed by a third party) contribution to the track's test generator.
Perhaps, rather than prolong this PR further, we can create an issue on the subject of converting the tests to a generator.
"topics": [ | ||
"data_structures", | ||
"lists", | ||
"recursion" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a syntax error. Our CI should definitely have caught this.
"recursion" | |
"recursion" | |
] |
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is unnecessary to the subject of the PR.
(Also, a CI check should probably have failed here. Considering how CI didn't catch a syntax error, perhaps configlet fmt .
isn't run at all. I'll open an issue to investigate.)
|
||
(env | ||
(dev | ||
(flags (:standard -warn-error -A)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice that most (but not all of) the files you generate don't have line termination and the files generated by configlet
do.
I don't have my development computer at hand, so I can't say if we are consistent about this across the track.
The easiest consistency we could aim for is across single exercises, which I think we should aim for either way.
Since README.md is forced to have line endings, I think this and other files should have, too.
Feel free to object and argue otherwise.
No description provided.