Ticket #1445: example.scm

File example.scm, 679 bytes (added by megane, 6 years ago)
Line 
1(use srfi-69)
2
3(: make-int-to-symbol (-> (struct hash-table (fixnum symbol))))
4(define (make-int-to-symbol)
5  (make-hash-table))
6
7(hash-table-set! (make-int-to-symbol) 'foo 2)
8
9(hash-table-set! (hash-table-copy (the (struct hash-table #f) (make-int-to-symbol))) 'foo 2)
10
11(: foo ((struct hash-table (fixnum)) -> fixnum))
12(define (foo ht)
13  (hash-table-size ht))
14
15(print (foo (make-int-to-symbol)))
16
17(: print-symbol (symbol -> *))
18(define (print-symbol s)
19  (print s))
20
21(: add-numbers (number number -> number))
22(define (add-numbers a b)
23  (+ a b))
24
25(: bar (forall (t) ((t -> *) (t t -> t) t t -> *)))
26(define (bar pr op a b)
27  (pr (op a b)))
28
29(bar print-symbol add-numbers 'a 'b)