/[svn]/web/overloading.cd
ViewVC logotype

Contents of /web/overloading.cd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 578 - (show annotations)
Tue Jul 10 17:45:59 2007 UTC (5 years, 11 months ago) by abate
File size: 804 byte(s)
[r2003-07-05 09:56:04 by cvscast] Beppe small change in the examples

Original author: cvscast
Date: 2003-07-05 09:56:04+00:00
1 type Person = FPerson | MPerson
2 type FPerson = <person gender = "F">[ Name Children ]
3 type MPerson = <person gender = "M">[ Name Children ]
4 type Children = <children>[ Person* ]
5 type Name = <name>[ PCDATA ]
6
7 type Man = <man name=String>[ Sons Daughters ]
8 type Woman = <woman name=String>[ Sons Daughters ]
9 type Sons = <sons>[ Man* ]
10 type Daughters = <daughters>[ Woman* ]
11
12 let fun split ({{MPerson -> Man ; FPerson -> Woman}})
13 <person gender=g>[ <name>n <children>[(mc::MPerson | fc::FPerson)*] ] ->
14 (* the above pattern collects all the MPerson in mc, and all the FPerson in fc *)
15 let tag = match g with "F" -> `woman | "M" -> `man in
16 let s = map mc with x -> split x in
17 let d = map fc with x -> split x in
18 <(tag) name=n>[ <sons>s <daughters>d ] ;;

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