Since in Scala lists are actually build like (here for List(1,2,3)
) this:
[ 1 , [ 2, [ 3 , Nill ] ] ] // (pseudo-code)
it is more efficient to pretend new elements and that is why ::
is right associative (all explained in https://stackoverflow.com/a/1162980/4533188) - to be better readable (here 1 :: 2 :: 3
). That answers my question, why it's good to have right association in the first place. But why didn't the designers of Lists simply construct them like
[ Nill , [ 3, [ 2 , 1 ] ] ] // (pseudo-code)
internally and use conventional left association?
Here in a graphic what my pseudo-code is supposed to mean (since it does not show the "links" of the linked list):