; arithmetic sequence
(define (seq? xs)
(let* ((mn (apply min xs))
(mx (apply max xs))
(len (length xs))
(diff (/ (- mx mn) (- len 1))))
(if (not (integer? diff)) #f
(= (* len (+ len 1) 1/2)
(apply +
(map (lambda (x)
(if (zero? (remainder x diff))
(quotient x diff)
0))
(map (lambda (x) (- x mn (- diff)))
xs)))))))
(display (seq? '(1 3 5 7 9))) (newline)
(display (seq? '(1 4 5 6 9))) (newline)
OyBhcml0aG1ldGljIHNlcXVlbmNlCgooZGVmaW5lIChzZXE/IHhzKQogIChsZXQqICgobW4gKGFwcGx5IG1pbiB4cykpCiAgICAgICAgIChteCAoYXBwbHkgbWF4IHhzKSkKICAgICAgICAgKGxlbiAobGVuZ3RoIHhzKSkKICAgICAgICAgKGRpZmYgKC8gKC0gbXggbW4pICgtIGxlbiAxKSkpKQogICAgKGlmIChub3QgKGludGVnZXI/IGRpZmYpKSAjZgogICAgICAoPSAoKiBsZW4gKCsgbGVuIDEpIDEvMikKICAgICAgICAgKGFwcGx5ICsKICAgICAgICAgICAobWFwIChsYW1iZGEgKHgpCiAgICAgICAgICAgICAgICAgIChpZiAoemVybz8gKHJlbWFpbmRlciB4IGRpZmYpKQogICAgICAgICAgICAgICAgICAgICAgKHF1b3RpZW50IHggZGlmZikKICAgICAgICAgICAgICAgICAgICAgIDApKQogICAgICAgICAgICAgICAgKG1hcCAobGFtYmRhICh4KSAoLSB4IG1uICgtIGRpZmYpKSkKICAgICAgICAgICAgICAgICAgICAgeHMpKSkpKSkpCgooZGlzcGxheSAoc2VxPyAnKDEgMyA1IDcgOSkpKSAobmV3bGluZSkKKGRpc3BsYXkgKHNlcT8gJygxIDQgNSA2IDkpKSkgKG5ld2xpbmUp