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

implement linked-list exercise #372

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

voila
Copy link
Contributor

@voila voila commented Oct 5, 2019

No description provided.

Copy link
Contributor

@sshine sshine left a 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:

https://stackoverflow.com/questions/1844195/doubly-linked-list-in-a-purely-functional-programming-language

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

@voila
Copy link
Contributor Author

voila commented Oct 17, 2019

In a pure functional language, a doubly-linked list is not that interesting.

OCaml is not a purely functional language. I think it's interesting to see imperative stuff done with it too.

Copy link
Contributor

@sshine sshine left a 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.

Copy link
Contributor

@sshine sshine left a 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.

exercises/linked-list/dune-project Outdated Show resolved Hide resolved
@sshine
Copy link
Contributor

sshine commented Jan 10, 2020

Hi @voila, and sorry for post-poning this review for so long.

I'll look at it tomorrow morning!

Copy link
Contributor

@sshine sshine left a 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"
Copy link
Contributor

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.

Suggested change
"recursion"
"recursion"
]

Comment on lines -464 to +475
}
}
Copy link
Contributor

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))))
Copy link
Contributor

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.

Base automatically changed from master to main January 28, 2021 19:17
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.

3 participants