File: test589.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 (36 lines) | stat: -rw-r--r-- 995 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

;; Copyright (C) 2017 Tommi Höynälänmaa

;; Expected results: translation and running OK

(define-proper-program (tests test589)

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

  (define-param-proc assoc-set0 (%key %value)
		     (((al (:alist %key %value))
		       (x-key %key)
		       (x-value %value))
		      (:pair (:alist %key %value) <boolean>)
		      pure)
    (match-type al
      ((<null>) (cons null #f))
      ((al1 (:nonempty-alist %key %value))
       (let ((p-binding (car al1)))
	 (if (equal? (car p-binding) x-key)
	     (cons
	      (cons
	       (cons x-key x-value)
	       (car (assoc-set0 (cdr al1) x-key x-value)))
	      #t)
	     (let ((x (assoc-set0 (cdr al1) x-key x-value)))
	       (cons
		(cons (car al1)
		      (car x))
		(cdr x))))))))

  (define-main-proc (() <none> nonpure)
    (let ((al '((abc . 1) (def . 2) (ghi . 3))))
      (console-display-line (assoc-set0 al 'jkl 5))
      (console-display-line (assoc-set0 al 'def 6)))))