Reversing
A reversing operation produces elements of a sequence in the opposite order, either by modifying the source or returning a reversed result.
Fabulous Adventures in Data Structures and Algorithms
Reverse is a method that constructs a new immutable linked list containing the input list's items in reverse order.
- How it is used
- Builds a reversed immutable list and transfers queued items between stacks when an immutable queue needs a new dequeue stack.
- How deep it goes
- Works through an iterative C# implementation, unchanged-input behavior, and O(n) time and extra-memory costs.
- Examples
- Tests reversal of a five-item integer list and uses stack reversal in an enqueue-and-dequeue sequence.
- What you can do after
- Build it from scratch with an empty accumulator and repeated Push calls, then apply the same pattern to an immutable queue.
Read how Fabulous Adventures in Data Structures and Algorithms explains reversing →
Python How-To
The reverse method is a Python list method that reverses a list in place and returns None.
- How it is used
- Use reversing to mutate a list into reverse order before subsequent readable, left-to-right operations.
- How deep it goes
- Defines in-place mutation and the None return, then contrasts reverse() with reversed() and negative-step slicing.
- Examples
- Demonstrates reversing before slicing and contrasts it with iterating through reversed(tasks).
- What you can do after
- Apply it to reverse an existing list in place and avoid treating its None return as reversed data.
The Quick Python Book, Fourth Edition
The reverse method is a Python list operation that reverses the order of elements in the list in place.
- How it is used
- Applies an in-place operation when a list’s element order must be reversed.
- How deep it goes
- Defines the specialized in-place operation and demonstrates its output, without discussing implementation internals.
- Examples
- Demonstrates reversing [1, 3, 5, 6, 7] to [7, 6, 5, 3, 1].
- What you can do after
- Apply the reverse method to change an existing list from forward order to backward order.
Read how The Quick Python Book, Fourth Edition explains reversing →
Also covered in
- Tiny Python Projects: Learn coding and testing with puzzles and games
- Python Workout, Second Edition
- Get Programming: Learn to code with Python
- Clojure: The Essential Reference
- Python Workout: 50 ten-minute exercises
- Learn Haskell by Example
- Learn Rust in a Month of Lunches
What to know first
- listA list is an ordered collection of elements arranged in a sequence.
- stringA string is a programming-language value representing textual data as an ordered sequence of characters or encoded units.
- integerAn integer is a whole-number mathematical value, including negative numbers, zero, and positive numbers, with no fractional part.
- iteratorAn iterator is an object or abstraction that provides successive values from a collection or other data source through a traversal interface.
Related concepts
- persistent listproduces · A persistent list is an immutable ordered list whose updates produce new versions while preserving earlier versions, typically through structural sharing.
- listuses · A list is an ordered collection of elements arranged in a sequence.
- iteratorproduces · An iterator is an object or abstraction that provides successive values from a collection or other data source through a traversal interface.
- lazy evaluationkind of · Lazy evaluation is an evaluation strategy that defers computing an expression until its value is needed, potentially avoiding the computation entirely.
- memoizationused by · Memoization is an optimization technique that stores results of computations with their inputs so later evaluations with equivalent inputs can reuse them without recomputation.
- rangeuses · A language or API construct that represents or generates an ordered sequence or interval of values, with its bounds and any step interpreted according to that language or API.
Questions about reversing
What is reversing?
A reversing operation produces elements of a sequence in the opposite order, either by modifying the source or returning a reversed result.
Which Manning books explain reversing?
Fabulous Adventures in Data Structures and Algorithms, Python How-To and The Quick Python Book, Fourth Edition.
What should I know before learning reversing?
Manning books that teach reversing usually introduce list, string, integer and iterator first.
What is reversing a kind of?
Reversing is a kind of lazy evaluation. Lazy evaluation is an evaluation strategy that defers computing an expression until its value is needed, potentially avoiding the computation entirely.
What is reversing also called?
Reversing is also called reverse or reversed.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


