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


 
(define friends '( albert ludwig elvis 🌀))
 
(for-each write friends)→  albert ludwig elvis 🌀
 
; for loop
(for ((friend friends)) (write friend)) → albert ludwig elvis 🌀
 
; map a function
(map string-upcase friends)  → ("ALBERT" "LUDWIG" "ELVIS" "🌀")
(map string-randcase friends) → ("ALBerT" "LudWIG" "elVis" "🌀")
 
; recursive way
(define (rscan L)
    (unless (null? L) 
        (write (first L)) 
         (rscan (rest L))))
 
(rscan friends)  →  albert ludwig elvis 🌀
 
; folding a list
; check that ∑ 1..n = n (n+1)/2
 
(define L (iota 1001))
(foldl + 0 L) → 500500 ; 1000 * 1001 / 2
 
 