Applying a Procedure to Successive Elements of a List
; Here’s a unary function for a special case
; of addition:
> (add1 20)
21
; Here’s custom-made recursive function:
> (define (increment-each lst)
(if (null? lst) ()
(cons (add1 (car lst))
(increment-each (cdr lst))
) ) )
INCREMENT-EACH
> (increment-each '(1 2 3 4 99.9))
(2 3 4 5 100.9)
Previous slide
Next slide
Back to first slide
View graphic version