;; -*-theme-d-*-

;; Copyright (C) 2015 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 test346)


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


  (define-simple-proc my-cons (((l (rest <object>))) <object> pure)
    (cons (d-list-ref l 0) (d-list-ref l 1)))


  (define-simple-proc my-proc1 (((i <object>)) <object> pure)
    (let ((i-result (+ (cast <integer> i) 1)))
      i-result))


  (define-simple-proc my-proc2 (((i <object>)) <object> nonpure)
    (let ((i-result (+ (cast <integer> i) 1)))
      (console-display-line i-result)
      i-result))


  (define-simple-proc my-proc3 (((l (rest <object>)))
				<object>
				nonpure)
    (let ((pr-result (cons (d-list-ref l 0) (d-list-ref l 1))))
      (console-display-line pr-result)
      pr-result))


  (define-simple-proc my-proc4 (((l (rest <object>)))
				<none>
				nonpure)
    (console-display (d-list-ref l 0))
    (console-display " ")
    (console-display-line (d-list-ref l 1)))


  (define main
    (lambda (() <none> nonpure)
      (let ((l1 (d-list 1 2 3 4 5))
	    (l2 (d-list 'a 'b 'c 'd 'e)))
	(console-display-line (d-car l1))
	(console-display-line (d-cdr l2))
	(console-display-line (d-list-ref l1 2))
	(console-display-line (d-map1 my-proc1 l1))
	(console-display-line (d-map-nonpure1 my-proc2 l1))
	(d-for-each1 console-display-line l2)
	(console-display-line (d-map my-cons l1 l2))
	(console-display-line (d-map-nonpure my-proc3 l1 l2))
	(d-for-each my-proc4 l1 l2)
	(console-display-line (d-append l1 l2))))))
