Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (sum-consecutive list state)
- (set! state (if (null? state)
- (first list)
- state))
- (if (= (length list) 1)
- (if (= state (first list))
- state
- 0)
- (if (= (first list) (second list))
- (+ (first list) (sum-consecutive (rest list) state)) 0)))
- (sum-consecutive '(2 2 1 2) null)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement