Anonymous user
Singly-linked list/Element definition: Difference between revisions
Singly-linked list/Element definition (view source)
Revision as of 10:50, 23 September 2008
, 15 years ago→{{header|Python}}: Colourize
(Logo) |
m (→{{header|Python}}: Colourize) |
||
Line 244:
The Node class implements also iteration for more Pythonic iteration over linked lists.
<python>class Node:▼
▲class Node:
def __init__(self, value, next=None):
self.value = value
Line 253 ⟶ 252:
while node:
yield node
node = node.next</python>
(Note that in Python you would always use the built-in list structure for this task, except for the specific case, such as this, when you are asked to show how you might implement the function without using the list type).
|