PPT Slide
Doubling the Values of All Elements of a List
( defun double ( x )
( if ( null x ) NIL
( cons ( * ( first x ) 2 )
( double ( rest x ) ) ) ) )
( double ' ( 2 0 6 ) )
( cons 4 ( double ' ( 0 6 ) ) )
( cons 0 ( double ' ( 6 ) ) )
( cons 12 ( double NIL ) )
( 4 0 12 )
Summing a List
( defun sum ( L )
( if ( null L ) 0
( + ( first L ) ( sum ( rest L ) ) ) ) )
1.37
Previous slide
Next slide
Back to first slide
View graphic version