~jojo/Carth

ref: 2d64043ef7cdff3d025dfe01dfc69e9c69236b68 Carth/examples/sicp.carth -rw-r--r-- 343 bytes
2d64043eJoJo Verify LLVM module before compiling to catch errors 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(define main
  (display (concat (Cons "Hello" (Cons ", " (Cons "World!" Nil))))))

(define concat
  (foldr ++ ""))

(define (foldr f init)
  (fun-match
    [Nil init]
    [(Cons x xs) (Cons (f x) (foldr f init xs))]))

(define ++
  (fun-match
    [Nil snd]
    [(Cons x xs) (. (Cons x) (++ xs))]))

(define (const c x) c)
(define (snd a b) b)