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

Diff of /tests/overloading.cd

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 34 by abate, Tue Jul 10 16:59:39 2007 UTC revision 35 by abate, Tue Jul 10 16:59:43 2007 UTC
# Line 1  Line 1 
1  type Person = FPerson | MPerson;;  type Person = FPerson | MPerson;;
2  type FPerson = <person gender="F">[ Name Children ];;  type FPerson = <person gender=1>[ Name Children ];;
3  type MPerson = <person gender="M">[ Name Children ];;  type MPerson = <person gender=2>[ Name Children ];;
4  type Children = <children>[Person*];;  type Children = <children>[Person*];;
5  type Name = <name>[String];;  type Name = <name>[String];;
6    
# Line 9  Line 9 
9  type Sons = <sons>[ Man* ];;  type Sons = <sons>[ Man* ];;
10  type Daughters = <daughters>[ Woman* ];;  type Daughters = <daughters>[ Woman* ];;
11    
 let fun sort (MPerson \(\synarrow\) Man ; FPerson \(\synarrow\) Woman)  
    <person gender=g>[ n <children>[(mc::MPerson | fc::FPerson)*] ] \mred  
        let tag = match g with "M" \mred `man | "F" \mred `woman in  
        let s = map mc with x \mred sort x in  
        let d = map fc with x \mred sort x in  
            <(tag)>[ n  <sons>s  <daughters>d ];;  
12    let fun sort (MPerson -> Man ; FPerson -> Woman)
13       <person gender=g>[ n <children>[(mc::MPerson | fc::FPerson)*] ] ->
14           let tag = match g with 1 -> `woman | 2 -> `man in
15           let s = map mc with x -> sort x in
16           let d = map fc with x -> sort x in
17               <(tag)>[ n  <sons>s  <daughters>d ] in sort;;

Legend:
Removed from v.34  
changed lines
  Added in v.35

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