fork download
  1. ; shuffle an array
  2.  
  3. (define (leetcode1470 input-list)
  4. (let loop1 ((turtles input-list) (hares input-list) (tnorf (list)))
  5. (if (pair? hares)
  6. (loop1 (cdr turtles) (cddr hares) (cons (car turtles) tnorf))
  7. (let loop2 ((tnorf tnorf) (kcab (reverse turtles)) (result (list)))
  8. (if (pair? tnorf)
  9. (loop2 (cdr tnorf) (cdr kcab)
  10. (cons (car tnorf) (cons (car kcab) result)))
  11. result)))))
  12.  
  13. (display (leetcode1470 '(1 2 3 4 a b c d))) (newline)
Success #stdin #stdout 0.01s 7892KB
stdin
Standard input is empty
stdout
(1 a 2 b 3 c 4 d)