KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In Scala, there is reverse method for lists. What is the complexity of this method? Is it better to simply use the original list and always remember that the list is the reverse of what we expect, or to explicitly use reverse before operating on it. EDIT: What I am really interested in is to get the last two elements of the original list (or the first two of the reversed list). So I would do something like: val myList = origList.reverse val a = myList(0) val b = myList(1) This is not in a loop, just a one-time thing in my library... but if someone else uses the library and puts it in a loop, it is not under my control.
Tags (comma-separated)
Save Edits
Cancel