Singly-Linked List (element)
singly-linked list
Using this method, insert an element C into a list comprised of elements A->B, following element A.

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 (insert-after lst target item) 
    (when (null? lst) (error "cannot insert in" null)) 
    (let [(sub-list (member target lst))] 
        (if sub-list (set-cdr! sub-list (cons item (cdr sub-list))) ; make chirurgy if found
        (nconc lst item)))) ; else append item
 
(define L '(a b))
(insert-after L 'a 'c)
    L  → (a c b)
(insert-after L 'x 'y) 
    L → (a c b y)
 