Commit | Line | Data |
---|---|---|
b89fc215 LC |
1 | ;;; Pattern matching with `(ice-9 match)'. |
2 | ;;; | |
3 | ||
0658041d AW |
4 | (use-modules (ice-9 match) |
5 | (srfi srfi-9)) ;; record type (FIXME: See `t-records.scm') | |
0b5f0e49 LC |
6 | |
7 | (define-record-type <stuff> | |
8 | (%make-stuff chbouib) | |
9 | stuff? | |
10 | (chbouib stuff:chbouib stuff:set-chbouib!)) | |
11 | ||
12 | (define (matches? obj) | |
13 | ; (format #t "matches? ~a~%" obj) | |
14 | (match obj | |
9806a548 | 15 | (($ stuff) #t) |
0b5f0e49 LC |
16 | ; (blurps #t) |
17 | ("hello" #t) | |
18 | (else #f))) | |
19 | ||
20 | \f | |
21 | ;(format #t "go!~%") | |
22 | (and (matches? (%make-stuff 12)) | |
23 | (matches? (%make-stuff 7)) | |
24 | (matches? "hello") | |
25 | ; (matches? 'blurps) | |
26 | (not (matches? 66))) |