box-mixed.scm 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ;;; examples/box-dynamic-module/box-mixed.scm -- Scheme module using some
  2. ;;; functionality from the shared library libbox-module, but do not
  3. ;;; export procedures from the module.
  4. ;;; Commentary:
  5. ;;; This is the Scheme module box-mixed. It uses some functionality
  6. ;;; from the shared library libbox-module, but does not export it.
  7. ;;; Code:
  8. ;;; Author: Thomas Wawrzinek
  9. ;;; Date: 2001-06-08
  10. ;;; Changed: 2001-06-14 by martin, some commenting, cleanup and integration.
  11. (define-module (box-mixed))
  12. ;; First, load the library.
  13. ;;
  14. (load-extension "libbox-module" "scm_init_box")
  15. ;; Create a list of boxes, each containing one element from ARGS.
  16. ;;
  17. (define (make-box-list . args)
  18. (map (lambda (el)
  19. (let ((b (make-box)))
  20. (box-set! b el) b))
  21. args))
  22. ;; Map the procedure FUNC over all elements of LST, which must be a
  23. ;; list of boxes. The result is a list of freshly allocated boxes,
  24. ;; each containing the result of an application of FUNC.
  25. (define (box-map func lst)
  26. (map (lambda (el)
  27. (let ((b (make-box)))
  28. (box-set! b (func (box-ref el)))
  29. b))
  30. lst))
  31. ;; Export the procedures, so that they can be used by others.
  32. ;;
  33. (export make-box-list box-map)
  34. ;;; End of file.