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
6336424b
Commit
6336424b
authored
Jul 10, 2007
by
Pietro Abate
Browse files
[r2002-10-21 22:28:49 by cvscast] Empty log message
Original author: cvscast Date: 2002-10-21 22:31:15+00:00
parent
8adc812a
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/overloading.cd
View file @
6336424b
type Person = FPerson | MPerson;;
type FPerson = <person gender=
"F"
>[ Name Children ];;
type MPerson = <person gender=
"M"
>[ Name Children ];;
type FPerson = <person gender=
1
>[ Name Children ];;
type MPerson = <person gender=
2
>[ Name Children ];;
type Children = <children>[Person*];;
type Name = <name>[String];;
...
...
@@ -9,9 +9,9 @@ type Woman = <woman>[ Name Sons Daughters ];;
type Sons = <sons>[ Man* ];;
type Daughters = <daughters>[ Woman* ];;
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 ];;
\ No newline at end of file
let fun sort (MPerson -> Man ; FPerson -> Woman)
<person gender=g>[ n <children>[(mc::MPerson | fc::FPerson)*] ] ->
let tag = match g with 1 -> `woman | 2 -> `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 sort;;
\ No newline at end of file
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