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
|
;; -*-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 test463)
(import (standard-library core)
(standard-library console-io))
(declare <my-rec-proc> :union)
(define <my-rec-proc> (:union
(:procedure
((:uniform-list <integer>)
(:procedure (<integer>) <integer> pure)
<my-rec-proc>)
(:uniform-list <integer>)
pure)
<null>))
(define <my-nonempty-rec-proc>
(:procedure
((:uniform-list <integer>)
(:procedure (<integer>) <integer> pure)
<my-rec-proc>)
(:uniform-list <integer>)
pure))
(define-simple-proc my-map (((l (:uniform-list <integer>))
(proc (:procedure (<integer>) <integer> pure))
(proc-next <my-rec-proc>))
(:uniform-list <integer>)
pure)
(match-type l
((<null>) null)
((l1 (:nonempty-uniform-list <integer>))
(begin
(cons (proc (car l1))
((cast <my-nonempty-rec-proc> 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))))
|