Hello everyone, when working on some exercises on exercism I got this error:
error: Syntax error
┌─ src/tracks_on_tracks_on_tracks.gleam:12:4
│
12 │ [..languages, language]
│ ^^^^^^^^^^^ I wasn't expecting elements after this
Lists are immutable and singly-linked, so to append items to them
all the elements of a list would need to be copied into a new list.
This would be slow, so there is no built-in syntax for it.
Hint: prepend items to the list and then reverse it once you are done.
Considering lists are immutable, wouldn't prepending items to the list also mean copying all elements into a new list? Moreso, wouldn't reversing a list also mean copying all elements into a new list? Is the compiler just optimizing those operations behind the scenes?