ProgrammingBasics
ProgrammingBasics copied to clipboard
Chapter 6 - preserving order of elements in a set
The Sets section:
assert listHalved.toSet.toList.head(3) equals list(0, 1, 2)
Isn't this implementation specific? What guarantees that a list converted to a set and converted back to a list preserves the original order? How about: listHalved.toSet.with(...).without(...).toList also preserve order?
assert listHalved.toList.at(3) equals 2 - here the "toList" conversion is not necessary, right?