Skip to content

Commit a9be2e2

Browse files
committed
Update README.md
1 parent 0945e0f commit a9be2e2

File tree

1 file changed

+1
-1
lines changed
  • 01-principles/day-01/src/main/scala/day01session04/lists

1 file changed

+1
-1
lines changed

01-principles/day-01/src/main/scala/day01session04/lists/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ In general and as mentioned by Odersky the idiomatic way is to use immutable and
151151

152152
## Performance and Memory consumption
153153

154-
What if you add or remove elements from a list? Prepending an element to an immutable list does internally no create a new list. Instead when you prepend an element to a list [a new pointer is created](http://stackoverflow.com/questions/2123290/why-is-the-operator-for-list-deprecated-in-scala#comment2062773_2123428) and links the element with the existing list. The List class does not offer an append operation - in fact there was an [+ operation but it was deprecated](http://stackoverflow.com/questions/2123290/why-is-the-operator-for-list-deprecated-in-scala). As stated [here](http://www.artima.com/pins1ed/next-steps-in-scala.html#step8):
154+
What if you add or remove elements from a list? Prepending an element to an immutable list does internally not create a new list. Instead when you prepend an element to a list [a new pointer is created](http://stackoverflow.com/questions/2123290/why-is-the-operator-for-list-deprecated-in-scala#comment2062773_2123428) and links the element with the existing list. The List class does not offer an append operation - in fact there was an [+ operation but it was deprecated](http://stackoverflow.com/questions/2123290/why-is-the-operator-for-list-deprecated-in-scala). As stated [here](http://www.artima.com/pins1ed/next-steps-in-scala.html#step8):
155155
> '... Class List does not offer an append operation, because the time it takes to append to a list grows linearly with the size of the list, whereas prepending with :: takes constant time. Your options if you want to build a list by appending elements is to prepend them, then when you're done call reverse; or use a ListBuffer, a mutable list that does offer an append operation, and when you're done call toList.'
156156
157157
There is another Stack Overflow [discussion about the performance and memory consumption](http://stackoverflow.com/questions/1308682/scala-mutable-vs-immutable-object-performance-outofmemoryerror) on Map dealing with one million elements.

0 commit comments

Comments
 (0)