PasteRack.org
Paste # 81738
2014-10-30 10:09:08

Fork as a new paste.

Paste viewed 30 times.


Embed:

  1. #lang racket
  2.  
  3. (define (combine lst)
  4.   (cond [(<= (length lst) 1) lst]
  5.         [(= (first lst) (second lst))
  6.          (cons (* 2 (first lst)) (combine (drop lst 2)))]
  7.         [else (cons (first lst) (combine (rest lst)))]))
  8.  
  9. (combine '(1 1 2))

=>

'(2 2)