expr-fun.l3 869 Bytes
Newer Older
Sapphie's avatar
Sapphie committed
1
2
3
4
;; In Emacs, open this file in -*- Scheme -*- mode

;; Test the "fun" expression

Sapphie's avatar
Sapphie committed
5
;;(@byte-write 73)
Sapphie's avatar
Sapphie committed
6

Sapphie's avatar
Sapphie committed
7
8
9
10
11
12
;;((fun (b) (@byte-write b)) 65)
;;((fun (b)
;;      (@byte-write b)
;;      (@byte-write (@+ b 1)))
;; 66)
;;(@byte-write ((fun (x) x) 68))
Sapphie's avatar
Sapphie committed
13

Sapphie's avatar
Sapphie committed
14
15
16
17
18
19
20
21
22
23
24
25
26
;;(let ((compose (fun (f g)
;;                    (fun (x) (f (g x)))))
;;      (succ (fun (x) (@+ x 1)))
;;      (twice (fun (x) (@+ x x))))
;;  (@byte-write ((compose succ twice) 34)))

(let 
  (
    (compose (fun (f)
                    (fun (x) (f x)))
    )
  )
  ((compose 1)))
Sapphie's avatar
Sapphie committed
27

Sapphie's avatar
Sapphie committed
28
29
30
31
;;((fun (x y z) #u)
;; (@byte-write 70)
;; (@byte-write 71)
;; (@byte-write 72))
Sapphie's avatar
Sapphie committed
32

Sapphie's avatar
Sapphie committed
33
34
35
36
37
38
39
40
;;(let* ((fact (fun (self x)
;;                   (if (@= 0 x)
;;                       1
;;                       (@* x (self self (@- x 1))))))
;;       (fix (fun (f x)
;;                 (f f x))))
;;  (if (@= (fix fact 5) 120)
;;      (@byte-write 73)))