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

rename Alist to SnocList, RevList, or other well-known name #390

Open
leque opened this issue Jan 7, 2023 · 3 comments
Open

rename Alist to SnocList, RevList, or other well-known name #390

leque opened this issue Jan 7, 2023 · 3 comments

Comments

@leque
Copy link
Contributor

leque commented Jan 7, 2023

I sometimes see people (including me) are puzzled1 by the name of src/alist.ml (accumulated list? not association list!). How about changing its name to something more well-known?

Candidates might be:

  • SnocList
  • RevList
  • AccList
  • ... (other candidates are welcome)

Footnotes

  1. (in Japanese) https://twitter.com/elpin1al/status/1244498976771944450

@gfngfn
Copy link
Owner

gfngfn commented Jan 7, 2023

Yes, by Alist I meant “accumulated lists.” I also understand the name is a bit confusing.

The module implements the following requirement:

  • An 'a t-typed value is essentially an ordered list of 'a-typed values.
  • Appending an element to the end can be done in $O(1)$.
  • Conversion of 'a t into 'a list can be done in $O(n)$ where $n$ is the number of elements.

Renaming this module seems to be a good idea for me. Thank you for the suggestion.

However, I’m not willing to rename it to RevList; it’s true that the requirement above is implemented by reversed singly linked lists, but that is an implementation detail, not an inevitable design. I prefer something like AccList.

@leque
Copy link
Contributor Author

leque commented Jan 7, 2023

I prefer SnocList; as the name suggesting, it is an ordered list with 𝑂(1) append-last operation (snoc). It is a FP-jargon, but it is easy to know its meaning by googling.

AccList is also OK to me.

@leque
Copy link
Contributor Author

leque commented Jan 8, 2023

(Or, use Queue.t, Queue.add , and Queue.to_seq |> List.of_seq. It is mutable, though.)

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

No branches or pull requests

2 participants