Inserting after all elements satisfying a predicate
; insert-right-by-pred ; takes a list and a Scheme value, inserts that value ; after all elements satisfying a predicate (define (insert-right-by-pred lst new) (cond [(null? lst) null] [(pred? (car lst)) (cons (car lst) (cons new (insert-right-by-pred (cdr lst) new)))] [else (cons (car lst) (insert-right-by-pred (cdr lst) new))]))