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
bba4d89d
Commit
bba4d89d
authored
Jul 10, 2007
by
Pietro Abate
Browse files
[r2002-11-11 16:11:38 by cvscast] Empty log message
Original author: cvscast Date: 2002-11-11 16:11:38+00:00
parent
60fbcdd4
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/overloading.cd
View file @
bba4d89d
...
...
@@ -4,18 +4,18 @@ type MPerson = <person gender="M">[ Name Children];;
type Children = <children>[Person*];;
type Name = <name>[ PCDATA ];;
type Man = <man
>[ Name
Sons Daughters ];;
type Woman = <woman
>[ Name
Sons Daughters ];;
type Man = <man
name=String>[
Sons Daughters ];;
type Woman = <woman
name=String>[
Sons Daughters ];;
type Sons = <sons>[ Man* ];;
type Daughters = <daughters>[ Woman* ];;
let fun sort (MPerson -> Man ; FPerson -> Woman)
<person gender=g>[ n <children>[(mc::MPerson | fc::FPerson)*] ] ->
<person gender=g>[
<name>
n <children>[(mc::MPerson | fc::FPerson)*] ] ->
let tag = match g with "F" -> `woman | "M" -> `man in
let s = map mc with x -> sort x in
let d = map fc with x -> sort x in
<(tag)
>[ n
<sons>s <daughters>d ]
in
<(tag)
name=n>[
<sons>s <daughters>d ]
;;
let base : Person =
<person gender="F">[
<name>"Veronique"
...
...
@@ -26,4 +26,15 @@ let base : Person =
]
]
]
in sort base;;
;;
sort base;;
(* compilation efficace avec _ a la place de person *)
let fun name (Person | Man | Woman -> String)
<person>[ <name>n ; _ ]
| <_ name=n>_ -> n;;
name base;;
name (sort base);;
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