1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
;; -*-theme-d-*-
;; Copyright (C) 2014, 2024 Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.
;; Expected results: translation and running OK
(define-proper-program (tests test186)
(import (standard-library core)
(standard-library console-io))
(define-param-proc my-proc1 (%type)
(((a %type) (b <integer>)) (:vector %type) pure)
(make-vector %type b a))
(define-param-proc my-proc2 (%type)
(((a %type) (b <integer>)) (:mutable-vector %type) pure)
(make-mutable-vector %type b a))
(define-param-proc my-proc3 (%type)
(((a %type) (b <integer>)) (:vector %type) pure)
(make-vector %type b a))
(define-param-proc my-proc4 (%type)
(((a %type) (b <integer>)) (:mutable-vector %type) pure)
(make-mutable-vector %type b a))
(define-param-proc-alt display-vector (%type)
(lambda (((v (:vector %type))) <none> nonpure)
(let ((len (vector-length v)))
(let-mutable ((j <integer> 0))
(until ((>= j len))
(console-display (vector-ref v j))
(console-newline)
(set! j (+ j 1)))))))
(define-param-proc-alt display-mutable-vector (%type)
(lambda (((v (:mutable-vector %type))) <none> nonpure)
(let ((len (mutable-vector-length v)))
(let-mutable ((j <integer> 0))
(until ((>= j len))
(console-display (mutable-vector-ref v j))
(console-newline)
(set! j (+ j 1)))))))
(define main
(lambda (() <none> nonpure)
(let ((vec1 (my-proc1 'abc 2))
(vec2 (my-proc2 1 3))
(vec3 (my-proc3 1.5 4))
(vec4 (my-proc4 #t 5)))
(display-vector vec1)
(display-mutable-vector vec2)
(display-vector vec3)
(display-mutable-vector vec4)
(console-newline)))))
|