fork(10) download
  1. ; a median-of-three killer sequence
  2.  
  3. (define (m3-killer n)
  4. (if (odd? n) (error 'm3-killer "length must be even")
  5. (let* ((k (/ n 2)) (ary (make-vector n #f)))
  6. (do ((i 1 (+ i 1))) ((< k i) ary)
  7. (when (odd? i)
  8. (vector-set! ary (- i 1) i)
  9. (vector-set! ary i (+ k i)))
  10. (vector-set! ary (+ k i -1) (+ i i))))))
  11.  
  12. (display (m3-killer 20)) (newline)
Success #stdin #stdout 0.01s 8672KB
stdin
Standard input is empty
stdout
#(1 11 3 13 5 15 7 17 9 19 2 4 6 8 10 12 14 16 18 20)