;; -*-theme-d-*-

;; Copyright (C) 2008-2013 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 test174)


  (import (standard-library core)
	  (standard-library console-io))


  (define-param-proc my-compare (%type)
		     (((vec (:value-vector %type)) (limit %type))
		      (:value-vector <boolean>)
		      force-pure)
    (let* ((len (value-vector-length vec))
	   (result (make-mutable-value-vector <boolean> len #f)))
	(do ((i <integer> 0 (+ i 1)))
	    ((>= i len)
	     (cast-value-vector-metaclass result))
	  (let ((r (value-vector-ref vec i)))
	    (mutable-value-vector-set! result i
				       (>= (+ r r) limit))))))


  (define-param-proc-alt display-value-vector (%type)
    (lambda (((v (:value-vector %type))) <none> nonpure)
      (let ((len (value-vector-length v)))
	(let-mutable ((j <integer> 0))
	  (until ((>= j len))
	    (console-display (value-vector-ref v j))
	    (console-newline)
	    (set! j (+ j 1)))))))


  (define-simple-proc main (() <none> nonpure)
    (let* ((my-vec1 (value-vector <real> 2.0 -1.5 4.0 5.6 10.1))
	   (res1 (my-compare my-vec1 3.0))
	   (my-vec2 (value-vector <integer> 2 -1 4 6 10))
	   (res2 (my-compare my-vec2 0)))
      (display-value-vector res1)
      (console-newline)
      (display-value-vector res2)
      (console-newline))))
