;; -*-theme-*-

;; Copyright (C) 2014  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-proc 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-proc my-proc (((r <real>)) <real> pure)
    (* 2.0 r))


  (define-simple-proc main (() <none> nonpure)
    (let* ((lst (list "apples" "oranges" "bananas" "blueberries" "cherries"))
	   (wrapper1 (make (:list-as-sequence <string>) lst))
	   (vec (vector <real> 1.5 2.5 3.5 4.5 5.5))
	   (wrapper2 (make (:vector-as-sequence <real>) vec))
	   (seq3 (sequence-map my-proc wrapper2)))
      (display-sequence wrapper1)
      (console-newline)
      (display-sequence wrapper2)
      (console-newline)
      (display-sequence seq3))))
