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
|
;; -*-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 test464)
(import (standard-library core)
(standard-library console-io))
(declare :my-rec-proc <param-logical-type>)
(define-param-logical-type :my-rec-proc (%type1 %type2)
(:union
(:procedure
((:uniform-list %type1)
(:procedure (%type1) %type2 pure)
(:my-rec-proc %type1 %type2))
(:uniform-list %type2)
pure)
<null>))
(define-param-logical-type :my-nonempty-rec-proc (%type1 %type2)
(:procedure
((:uniform-list %type1)
(:procedure (%type1) %type2 pure)
(:my-rec-proc %type1 %type2))
(:uniform-list %type2)
pure))
(define-param-proc my-map (%type1 %type2)
(((l (:uniform-list %type1))
(proc (:procedure (%type1) %type2 pure))
(proc-next (:my-rec-proc %type1 %type2)))
(:uniform-list %type2)
pure)
(match-type l
((<null>) null)
((l1 (:nonempty-uniform-list %type1))
(begin
(cons (proc (car l1))
((cast (:my-nonempty-rec-proc %type1 %type2) proc-next)
(cdr l1) proc my-map))))))
(define-simple-proc my-proc (((i <integer>)) <integer> pure)
(+ i 1))
(define-main-proc (() <none> nonpure)
(let* ((l1 '(1 2 3 4 5))
(l2 (my-map l1 my-proc my-map)))
(console-display-line l2))))
|