All pastes #935832 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-03-09 22:54 UTC
rendered paste body
1.
( define collectEvens
   ( lambda ( L )
      ( cond ( ( null? L ) '() )
             ( ( even? ( car L ) )
               ( cons ( car L )
                      ( collectEvens ( cdr L ) )
                      )
               )
             ( else ( collectEvens ( cdr L ) ) )
             )
      )
   )

2.

( define replace-nth
   ( lambda ( a b c )
      ( cond ( ( = a 1 ) ( cons b ( cdr c ) ) )
             ( else ( cons ( car c ) ( replace-nth ( - p 1 ) b ( cdr c ) ) ) )
             )
      )
   )

3.
( define consToEnd
   ( lambda ( a b )
      ( cond ( ( null? a ) ( cons b '() ) )
             ( else ( cons ( car b ) ( consToEnd a ( cdr b ) ) ) )
             )
      )
   )