inexact.scm 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ;;; R7RS (scheme inexact) library
  2. ;;; Copyright (C) 2024 Igalia, S.L.
  3. ;;;
  4. ;;; Licensed under the Apache License, Version 2.0 (the "License");
  5. ;;; you may not use this file except in compliance with the License.
  6. ;;; You may obtain a copy of the License at
  7. ;;;
  8. ;;; http://www.apache.org/licenses/LICENSE-2.0
  9. ;;;
  10. ;;; Unless required by applicable law or agreed to in writing, software
  11. ;;; distributed under the License is distributed on an "AS IS" BASIS,
  12. ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. ;;; See the License for the specific language governing permissions and
  14. ;;; limitations under the License.
  15. ;;; Commentary:
  16. ;;;
  17. ;;; R7RS (scheme inexact) implementation
  18. ;;;
  19. ;;; Code:
  20. (library (scheme inexact)
  21. (export sin cos tan
  22. asin acos atan
  23. log exp
  24. infinite? finite? nan?
  25. sqrt)
  26. (import (rename (hoot numbers)
  27. (infinite? %infinite?)
  28. (finite? %finite?)
  29. (nan? %nan?))
  30. (hoot syntax))
  31. (define (finite? x)
  32. (if (real? x)
  33. (%finite? x)
  34. (and (%finite? (real-part x))
  35. (%finite? (imag-part x)))))
  36. (define (infinite? x)
  37. (if (real? x)
  38. (%infinite? x)
  39. (or (%infinite? (real-part x))
  40. (%infinite? (imag-part x)))))
  41. (define (nan? x)
  42. (if (real? x)
  43. (%nan? x)
  44. (or (%nan? (real-part x))
  45. (%nan? (imag-part x))))))