Tag Archives: iter

Implementing a Stack in python

To implement a Stack in python, we simply need to extend the existing list class! class Stack(list): def push(self, data): self.append(data) def tos(self): if self: return self[-1] def peek(self, index): if self and 0 <= index < len(self): return self[index] def __iter__(self): if self: ptr = len(self) – 1 while ptr >= 0: yield self[ptr] […]

0  

Iterating over a custom ‘Jagged Array’ in Python

A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array of arrays." C# natively differentiates between a jagged and a multidimensional array. To iterate over a every single element of a Jagged Array in […]

0