utils.scm 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. ;;; guile-semver --- Semantic Version tooling for guile
  2. ;;; Copyright © 2017 Jelle Dirk Licht <jlicht@fsfe.org>
  3. ;;;
  4. ;;; This file is part of guile-semver.
  5. ;;;
  6. ;;; guile-semver is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or
  9. ;;; (at your option) any later version.
  10. ;;;
  11. ;;; guile-semver is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. ;;; General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with guile-semver. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (semver utils)
  19. #:export (juxt))
  20. (define (juxt . fns)
  21. "Returns the juxtaposition of FNS. The returned function returns a
  22. list containing the result of applying each function in FNS in order."
  23. (lambda (. v)
  24. (let loop ((acc '())
  25. (fns fns))
  26. (if (null? fns)
  27. (reverse acc)
  28. (loop (cons (apply (car fns) v) acc)
  29. (cdr fns))))))