File: test476.thp

package info (click to toggle)
theme-d 7.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,036 kB
  • sloc: lisp: 9,625; sh: 5,321; makefile: 715; ansic: 477
file content (68 lines) | stat: -rw-r--r-- 1,986 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;; -*-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


(define-proper-program (tests test476)


  (import (standard-library core)
	  (standard-library string-utilities)
	  (standard-library stream)
	  (standard-library console-io)
	  (standard-library object-string-conversion))


  (define-main-proc (() <none> nonpure)
    (let* ((l1 '(1 2 3 4 5))
	   (stm (list->stream l1))
	   (stm2 (stream-map
		  (lambda (((i <integer>)) <integer> pure)
		    (force-pure-expr (console-display-line "*1*"))
		    (+ i 1))
		  stm))
	   (tmp1 (begin (console-display-line "---1---") 0))
	   (l2 (stream->list stm2))
	   (stm3 (stream-map
		  (lambda (((i <integer>)) <real> pure) 
		    (force-pure-expr (console-display-line "*2*"))
		    (+ i 0.5))
		  stm))
	   (tmp1 (begin (console-display-line "---2---") 0))
	   (l3 (stream->list stm3))
	   (stm4 (:nonpure-stream <string>)
		 (stream-map-nonpure
		  (lambda (((i <integer>)) <string> nonpure)
		    (console-display-line "*")
		    (object->string i))
		  stm))
	   (tmp1 (begin (console-display-line "---3---") 0))
	   (l4 (nonpure-stream->list stm4)))
      (console-display-line l2)
      (console-display-line l3)
      (console-display-line l4)
      (stream-for-each (lambda (((r <real>)) <none> nonpure)
			 (console-display r)
			 (console-display ", "))
		       stm3)
      (console-newline)
      (console-display-line "---4---") 
      (console-display-line
       (nonpure-stream->list
	(let ((result
	       (nonpure-stream-map (lambda (((str <string>)) <string> nonpure)
				     (console-display-line str)
				     (string-append str "*"))
				   stm4)))
	  (console-display-line "---5---") 
	  result)))
      (nonpure-stream-for-each (lambda (((str <string>)) <none> nonpure)
				 (console-display str)
				 (console-display ", "))
			       stm4)
      (console-newline))
    0))