Singly-linked list/Reversal: Difference between revisions
m
→{{header|Wren}}: Minor tidy
imported>StraightDoubt (Added Common Lisp with various examples) |
m (→{{header|Wren}}: Minor tidy) |
||
Line 613:
However, it's also possible to reverse the LinkedList in place by successively exchanging elements at both ends. Internally, the 'exchange' method uses the indexer to swap elements.
<syntaxhighlight lang="
import "./iterate" for Reversed
Line 630:
// iterate backwards by creating a list internally
for (e in Reversed.new(sll)) System.write("%(e) ")
System.print("\n")
// reverse the linked list in place
|