/[svn]/website/trunk/web/funxml.cd
ViewVC logotype

Contents of /website/trunk/web/funxml.cd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3917 - (show annotations)
Tue Nov 20 13:57:40 2007 UTC (5 years, 5 months ago) by abate
File size: 1127 byte(s)
- Move the website directory outside the language distribution
1 type Bib = [ Book* ]
2 type Book = <book>[ Title Subtitle? Author+ ]
3 type Title = <title>[ PCDATA ]
4 type Subtitle = <subtitle>[ PCDATA ]
5 type Author = <author>[ PCDATA ]
6
7 let title(Book -> String) <book>[ <title>x _* ] -> x
8 let author(Book -> [Author+]) x -> x//Author
9
10 (* We annotate each book with a printing function for it *)
11
12 type FBook = Book -> String
13 type ABook = <book print=FBook>[ Title Subtitle? Author+ ]
14 type ABib = [ ABook* ]
15 (* Note that: ABook <= Book, ABib <= Bib *)
16
17 let set(<book>c : Book)(f : FBook) : ABook = <book print=f>c
18 let prepare(b : Bib) : ABib = map b with x -> set x title
19
20 (* We display the annotated bibliography *)
21
22 type Ul = <ul>[ Li+ ]
23 type Li = <li>[ PCDATA ]
24
25 let display (ABib -> Ul; ABook -> Li)
26 | <book print=f>_ & x -> <li>(f x)
27 | [] -> raise "Empty bibliography"
28 | p -> <ul>(map p with z -> display z)
29
30 (* We change the dispay function for some books *)
31
32 let change(p : Book -> Bool)(f : FBook)(b : ABib) : ABib =
33 map b with x -> if (p x) then set x f else x
34
35 type HasSub = <_>[ _* Subtitle _* ]
36
37 let change_if_sub =
38 change (fun (Book -> Bool) HasSub -> `true | _ -> `false)

CVS Admin">CVS Admin
ViewVC Help
Powered by ViewVC 1.1.5