; Two functions that are REALLY helpful in doing the poker hands project
; 
; differences
; Domain: A sentence of numbers
; Range: A sentence of numbers
;
; Example:
; > (differences '(3 6 10 2 8))
; '(3 4 -8 6)

(define (differences sent)
  (cond ((< (count sent) 2) '())
        (else (se (- (item 2 sent) (item 1 sent))
                  (differences (bf sent))))))
; consec
; Domain: A datum and a sentence
; Range: A number that is the longest consecutive sequence of the datum in the sentence
;
; Example:
; > (consec 'a '(b c a d a a a b a a))
; 3

(define (consec datum sent)
  (consec-helper datum sent 0 0))

; consec-helper
; Domain: Same datum and sentence for consec plus current streak and maximum streak parameters
; Range: A number that is the longest consecutive sequence of the datum in the sentence

(define (consec-helper datum sent current maximum)
  (cond ((empty? sent) maximum)
        ((equal? (first sent) datum)
         (consec-helper datum (bf sent) (+ current 1) (max (+ current 1) maximum)))
        (else (consec-helper datum (bf sent) 0 maximum))))