Advertisement
Guest User

Untitled

a guest
Dec 4th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.36 KB | None | 0 0
  1. (define (sum-consecutive list state)
  2.   (set! state (if (null? state)
  3.                (first list)
  4.                state))
  5.   (if (= (length list) 1)
  6.       (if (= state (first list))
  7.           state
  8.           0)
  9.       (if (= (first list) (second list))
  10.           (+ (first list) (sum-consecutive (rest list) state)) 0)))
  11.  
  12. (sum-consecutive '(2 2 1 2) null)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement