~peter-pearse/ubuntu/natty/guile-1.8/prop001

« back to all changes in this revision

Viewing changes to examples/box-dynamic-module/box-mixed.scm

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Schepler
  • Date: 2006-11-09 03:11:16 UTC
  • Revision ID: james.westby@ubuntu.com-20061109031116-hu0q1jxqg12y6yeg
Tags: upstream-1.8.1+1
ImportĀ upstreamĀ versionĀ 1.8.1+1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.