Traverse from the beginning of a singly-linked list to the end.



See also

 Array
 Associative array: Creation, Iteration
 Collections
 Compound data type
 Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
 Linked list
 Queue: Definition, Usage
 Set
 Singly-linked list: Element definition, Element insertion, List Traversal, Element Removal
 Stack


const std = @import("std");
 
pub fn main() anyerror!void {
    var l1 = LinkedList(i32).init();
 
    try l1.add(1);
    try l1.add(2);
    try l1.add(4);
    try l1.add(3);
 
    var h = l1.head;
 
    while (h) |head| : (h = head.next) {
        std.log.info("> {}", .{ head.value });
    }
}