fork(4) download
  1. ; arithmetic sequence
  2.  
  3. (define (seq? xs)
  4. (let* ((mn (apply min xs))
  5. (mx (apply max xs))
  6. (len (length xs))
  7. (diff (/ (- mx mn) (- len 1))))
  8. (if (not (integer? diff)) #f
  9. (= (* len (+ len 1) 1/2)
  10. (apply +
  11. (map (lambda (x)
  12. (if (zero? (remainder x diff))
  13. (quotient x diff)
  14. 0))
  15. (map (lambda (x) (- x mn (- diff)))
  16. xs)))))))
  17.  
  18. (display (seq? '(1 3 5 7 9))) (newline)
  19. (display (seq? '(1 4 5 6 9))) (newline)
Success #stdin #stdout 0.03s 8616KB
stdin
Standard input is empty
stdout
#t
#f