]> git.donarmstrong.com Git - lilypond.git/blob - guile18/examples/box-dynamic-module/box-mixed.scm
New upstream version 2.19.65
[lilypond.git] / guile18 / examples / box-dynamic-module / box-mixed.scm
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
5 ;;; Commentary:
6
7 ;;; This is the Scheme module box-mixed.  It uses some functionality
8 ;;; from the shared library libbox-module, but does not export it.
9
10 ;;; Code:
11
12 ;;; Author: Thomas Wawrzinek
13 ;;; Date: 2001-06-08
14 ;;; Changed: 2001-06-14 by martin, some commenting, cleanup and integration.
15
16 (define-module (box-mixed))
17
18 ;; First, load the library.
19 ;;
20 (load-extension "libbox-module" "scm_init_box")
21
22 ;; Create a list of boxes, each containing one element from ARGS.
23 ;;
24 (define (make-box-list . args)
25   (map (lambda (el)
26          (let ((b (make-box)))
27            (box-set! b el) b))
28        args))
29
30 ;; Map the procedure FUNC over all elements of LST, which must be a
31 ;; list of boxes.  The result is a list of freshly allocated boxes,
32 ;; each containing the result of an application of FUNC.
33 (define (box-map func lst)
34   (map (lambda (el)
35          (let ((b (make-box)))
36            (box-set! b (func (box-ref el)))
37            b))
38        lst))
39
40 ;; Export the procedures, so that they can be used by others.
41 ;;
42 (export make-box-list box-map)
43
44 ;;; End of file.