;; -*-theme-*-

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

;; Expected results: translation and running OK


(define-proper-program (examples sequence-test)


  (import (standard-library core)
	  (standard-library console-io)
	  (examples sequence)
	  (examples list-as-sequence)
	  (examples vector-as-sequence))


  (define-param-method display-sequence (%element)
  		     (((seq (:sequence %element))) <none> nonpure)
    (let ((len <integer> (sequence-length seq)))
      (do ((i <integer> 0 (+ i 1))) ((>= i len))
  	(console-display (sequence-ref seq i))
  	(console-newline))))


  (define-simple-method my-proc (((r <real>)) <real> pure)
    (* 2.0 r))


  (define-main-proc (() <none> nonpure)
    (console-display-line "*1*")
    (let* ((lst (list "apples" "oranges" "bananas" "blueberries" "cherries"))
	   (wrapper1 (create (:list-as-sequence <string>) lst))
	   (vec (vector <real> 1.5 2.5 3.5 4.5 5.5))
	   (tmp1 (begin (console-display-line "*2*") 0))
	   (wrapper2 (create (:vector-as-sequence <real>) vec))
	   (tmp2 (begin (console-display-line "*3*") 0))
	   (seq3 (sequence-map my-proc wrapper2)))
      (console-display-line "*4*")
      (display-sequence wrapper1)
      (console-newline)
      (display-sequence wrapper2)
      (console-newline)
      (display-sequence seq3))))
