Applying a Function to Successive Elements of a List
; Here’s a unary function with a funny name:
> (1+ 20)
21
; Here’s custom-made recursive function:
> (defun increment-each (lst)
(if (null lst) nil
(cons (1+ (first lst))
(increment-each (rest 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