fork download
  1. ; your code goes here
  2. (defun same-parity (n list)
  3. (loop for x in list
  4. with parity = (rem n 2)
  5. if (= (rem x 2) parity)
  6. collect x))
  7.  
  8. (defvar x (list 1 2 3 4 5 6 7 8 9 10))
  9.  
  10. (print (same-parity 3 x))
  11. (print (same-parity 2 x))
  12.  
Success #stdin #stdout 0s 10472KB
stdin
Standard input is empty
stdout
(1 3 5 7 9) 
(2 4 6 8 10)