main.scm 784 B

12345678910111213141516171819202122232425262728293031
  1. (import (ice-9 match))
  2. (define odd-times-appearing
  3. (λ (ints)
  4. ;; sorting inside the function, as it is an
  5. ;; implementation detail of how one finds odd times
  6. ;; appearing numbers in a list
  7. (let ([sorted (sort ints <)])
  8. (match sorted
  9. [() (error "no odd times appearing numbers in the given list")]
  10. [(a) a]
  11. [(a a rest ...) (odd-times-appearing rest)]
  12. [(a b rest ...) a]))))
  13. (odd-times-appearing '(1 7 1 7 3 7 3))
  14. (import (ice-9 match))
  15. (define (odd-times-appearing ints)
  16. (let ([sorted (sort ints <)])
  17. (match sorted
  18. [() (error "no odd times appearing numbers in the given list")]
  19. [(a) a]
  20. [(a a rest ...) (odd-times-appearing rest)]
  21. [(a b rest ...) a])))
  22. (odd-times-appearing '(1 7 1 7 3 7 3))