diff --git a/changelog.md b/changelog.md index 6e45d7b7d93d..33d199d82415 100644 --- a/changelog.md +++ b/changelog.md @@ -85,7 +85,7 @@ - Added `lists.copy` for shallow copying singly- and doubly linked lists. - `add` is now overloaded also for the concatenation of singly- and doubly linked lists; - an O(1) variation that consumes its argument, `addMove`, is also supplied. + an O(1) variation that consumes its argument, `addMoved`, is also supplied. ## Language changes diff --git a/lib/pure/collections/lists.nim b/lib/pure/collections/lists.nim index d14af32b2f17..9a6819af9afa 100644 --- a/lib/pure/collections/lists.nim +++ b/lib/pure/collections/lists.nim @@ -704,15 +704,15 @@ proc add*[T](L1: var DoublyLinkedList[T], L2: DoublyLinkedList[T]) {.since: (1, ## Appends a shallow copy of `L2` to the end of `L1`. runnableExamples: import sequtils - var a = [1, 2, 3].toDoublyLinkedList - let b = [4, 5].toDoublyLinkedList + var a = [1, 2, 3].toSinglyLinkedList + let b = [4, 5].toSinglyLinkedList a.add b assert a.toSeq == [1, 2, 3, 4, 5] assert b.toSeq == [4, 5] a.add a assert a.toSeq == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] - var tmp = L2.copy - L1.addMove tmp + var tmp = b.copy + a.addMoved tmp proc remove*[T](L: var DoublyLinkedList[T], n: DoublyLinkedNode[T]) = ## Removes a node `n` from `L`. Efficiency: O(1).