;; -*-theme-d-*-

;; Copyright (C) 2016 Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.

;; Expected results: translation and running OK
;; Expected output:
;;   ((1 . 1) (2 . 2) (3 . 3) (4 . 4) (5 . 5))
;;   ((1 . 10.5) (2 . 20.5) (3 . -30.5) (4 . 40.5) (5 . 50.5))
;;   ((100 . 100) (101 . 101) (102 . 102) (103 . 103))
;;   #t
;;   #f
;;   #f
;;   #t
;;   #t


(define-proper-program (tests test470)


  (import (standard-library core)
	  (standard-library basic-math)
	  (standard-library iterator)
	  (standard-library console-io))


  (define-simple-proc my-proc1 (((i <integer>)) (:pair <integer> <integer>)
				pure)
    (cons i i))


  (define-simple-proc my-proc2 (((i <integer>) (r <real>))
				(:pair <integer> <real>)
				pure)
    (cons i r))


  (define-simple-proc main (() <none> nonpure)
    (let* ((l1 '(1 2 3 4 5))
	   (l2 '(10.5 20.5 -30.5 40.5 50.5))
	   (v1 (mutable-vector <integer> 100 101 102 103))
	   (iter1 (get-list-iterator l1))
	   (l3 (iter-map1 my-proc1 iter1))
	   (iter2 (get-list-iterator l2))
	   (l4 (iter-map2 cons iter1 iter2))
	   (iter3 (get-mutable-vector-iterator v1))
	   (l5 (iter-map1 my-proc1 iter3))
	   (b1 (iter-every1 (lambda (((i <integer>)) <boolean> pure)
			      (>= i 0))
			    iter1))
	   (b2 (iter-every1 (lambda (((r <real>)) <boolean> pure)
			      (>= r 0.0))
			    iter2))
	   (b3 (iter-every2 (lambda (((i <integer>) (r <real>)) <boolean> pure)
			      (<= i r))
			    iter1 iter2))
	   (b4 (iter-every2 (lambda (((i <integer>) (r <real>)) <boolean> pure)
			      (<= i (r-abs r)))
			    iter1 iter2))
	   (b5 (iter-every2 (lambda (((i <integer>) (r <real>)) <boolean> pure)
			      (>= i r))
			    iter3 iter2)))
      (console-display-line l3)
      (console-display-line l4)
      (console-display-line l5)
      (console-display-line b1)
      (console-display-line b2)
      (console-display-line b3)
      (console-display-line b4)
      (console-display-line b5))))
