Mzscheme - fix for running examples during 'make check-examples' - they don't run very well though\!
This commit is contained in:
parent
62638bfd15
commit
2b2305cce9
5 changed files with 6 additions and 5 deletions
|
|
@ -747,7 +747,7 @@ mzscheme_cpp: $(SRCS)
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
mzscheme_run:
|
||||
$(RUNTOOL) $(MZSCHEME) -r $(MZSCHEME_SCRIPT) $(RUNPIPE)
|
||||
env LD_LIBRARY_PATH=. $(RUNTOOL) $(MZSCHEME) -r $(MZSCHEME_SCRIPT) $(RUNPIPE)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Version display
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# see top-level Makefile.in
|
||||
multimap
|
||||
simple
|
||||
std_vector
|
||||
|
|
|
|||
27
Examples/mzscheme/multimap/runme.scm
Normal file
27
Examples/mzscheme/multimap/runme.scm
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
;; run with mzscheme -r runme.scm
|
||||
|
||||
(load-extension "example.so")
|
||||
|
||||
; Call the GCD function
|
||||
|
||||
(define x 42)
|
||||
(define y 105)
|
||||
(define g (gcd x y))
|
||||
|
||||
(display "The gcd of ")
|
||||
(display x)
|
||||
(display " and ")
|
||||
(display y)
|
||||
(display " is ")
|
||||
(display g)
|
||||
(newline)
|
||||
|
||||
; Call the gcdmain() function
|
||||
(gcdmain #("gcdmain" "42" "105"))
|
||||
|
||||
|
||||
(display (count "Hello World" #\l))
|
||||
(newline)
|
||||
|
||||
(display (capitalize "hello world"))
|
||||
(newline)
|
||||
24
Examples/mzscheme/simple/runme.scm
Normal file
24
Examples/mzscheme/simple/runme.scm
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
;; run with mzscheme -r runme.scm
|
||||
|
||||
(load-extension "example.so")
|
||||
|
||||
(display (get-time))
|
||||
|
||||
(printf "My-variable = ~a~n" (my-variable))
|
||||
|
||||
(let loop ((i 0))
|
||||
(when (< i 14) (begin (display i)
|
||||
(display " factorial is ")
|
||||
(display (fact i))
|
||||
(newline)
|
||||
(loop (+ i 1)))))
|
||||
|
||||
(let loop ((i 1))
|
||||
(when (< i 250)
|
||||
(begin
|
||||
(let loopi ((j 1))
|
||||
(when (< j 250) (begin (my-variable (+ (my-variable) (mod i j)))
|
||||
(loopi (+ j 1)))))
|
||||
(loop (+ i 1)))))
|
||||
|
||||
(printf "My-variable = ~a~n" (my-variable))
|
||||
54
Examples/mzscheme/std_vector/runme.scm
Normal file
54
Examples/mzscheme/std_vector/runme.scm
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
;; run with mzscheme -r runme.scm
|
||||
|
||||
(load-extension "example.so")
|
||||
|
||||
; repeatedly invoke a procedure with v and an index as arguments
|
||||
(define (with-vector v proc size-proc)
|
||||
(let ((size (size-proc v)))
|
||||
(define (with-vector-item v i)
|
||||
(if (< i size)
|
||||
(begin
|
||||
(proc v i)
|
||||
(with-vector-item v (+ i 1)))))
|
||||
(with-vector-item v 0)))
|
||||
|
||||
(define (with-intvector v proc)
|
||||
(with-vector v proc intvector-length))
|
||||
(define (with-doublevector v proc)
|
||||
(with-vector v proc doublevector-length))
|
||||
|
||||
(define (print-doublevector v)
|
||||
(with-doublevector v (lambda (v i) (display (doublevector-ref v i))
|
||||
(display " ")))
|
||||
(newline))
|
||||
|
||||
|
||||
; Call average with a Scheme list...
|
||||
|
||||
(display (average '(1 2 3 4)))
|
||||
(newline)
|
||||
|
||||
; ... or a wrapped std::vector<int>
|
||||
(define v (new-intvector 4))
|
||||
(with-intvector v (lambda (v i) (intvector-set! v i (+ i 1))))
|
||||
(display (average v))
|
||||
(newline)
|
||||
(delete-intvector v)
|
||||
|
||||
; half will return a Scheme vector.
|
||||
; Call it with a Scheme vector...
|
||||
|
||||
(display (half #(1 1.5 2 2.5 3)))
|
||||
(newline)
|
||||
|
||||
; ... or a wrapped std::vector<double>
|
||||
(define v (new-doublevector))
|
||||
(map (lambda (i) (doublevector-push! v i)) '(1 2 3 4))
|
||||
(display (half v))
|
||||
(newline)
|
||||
|
||||
; now halve a wrapped std::vector<double> in place
|
||||
(halve-in-place v)
|
||||
(print-doublevector v)
|
||||
(delete-doublevector v)
|
||||
|
||||
Loading…
Reference in a new issue