Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
7a1cb28f
Commit
7a1cb28f
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2002-10-24 14:25:17 by cvscast] Empty log message
Original author: cvscast Date: 2002-10-24 14:25:17+00:00
parent
a054f94b
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/overloading.cd
View file @
7a1cb28f
type Person = FPerson | MPerson;;
type FPerson = <person gender=["F"]>[ Name Children ];;
type MPerson = <person gender=["M"]>[ Name Children ];;
type Children = <children>[Person*];;
type Name = <name>[String];;
type Person = FPerson | MPerson;; type FPerson = <person gender='F'>[
Name Children ];; type MPerson = <person gender='M'>[ Name Children
];; type Children = <children>[Person*];; type Name = <name>[String];;
type Man = <man>[ Name Sons Daughters ];;
type Woman = <woman>[ Name Sons Daughters ];;
...
...
@@ -11,7 +9,7 @@ type Daughters = <daughters>[ Woman* ];;
let fun sort (MPerson -> Man ; FPerson -> Woman)
<person gender=g>[ n <children>[(mc::MPerson | fc::FPerson)*] ] ->
let tag = match g with
["F"]
-> `woman |
["M"]
-> `man in
let tag = match g with
'F'
-> `woman |
'M'
-> `man in
let s = map mc with (x & MPerson) -> sort x in
let d = map fc with x -> sort x in
<(tag)>[ n <sons>s <daughters>d ]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment