Hi, I couldn't find an O(1) operation that concatenates two lists. Something like this: proc concat[T](a: var SinglyLinkedList[T], b: SinglyLinkedList[T]) = ## Concatenates (adds to the end) `b` to `a`. Efficiency: O(1). ## Note that the two lists share structure after the operation. if a.tail != nil: a.tail.next = b.head a.tail = b.tail if a.head == nil: a.head = b.head Run
Since one of the merits of the linked list representation is constant-time concatenation, I would have thought this basic enough to include in the standard library. Or did I miss something? (Quite probable, as I'm new to Nim...)